-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from crosscite/disable_nondc
Remove support for non DC
- Loading branch information
Showing
1 changed file
with
4 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,28 +14,10 @@ def show | |
if response.status == 200 | ||
@metadata = Bolognese::Metadata.new(input: response.body.fetch("data", nil), from: "datacite_json") | ||
else | ||
url = "https://api.crossref.org/works/#{@doi}/transform/application/[email protected]" | ||
response = Maremma.get(url, accept: "text/xml", raw: true, timeout: 2) | ||
|
||
if response.status == 200 | ||
string = response.body.fetch("data", nil) | ||
string = Nokogiri::XML(string, nil, 'UTF-8', &:noblanks).to_s if string.present? | ||
@metadata = Bolognese::Metadata.new(input: string, from: "crossref") | ||
else | ||
ra = get_doi_ra(@doi) | ||
|
||
if %w(mEDRA JaLC).include?(ra) | ||
# we fetch the Citeproc JSON from DOI content negotiation for the other RAs that support this | ||
url = "https://doi.org/#{@doi}" | ||
response = Maremma.get(url, accept: "application/vnd.citationstyles.csl+json", raw: true) | ||
fail AbstractController::ActionNotFound if response.status != 200 | ||
|
||
string = response.body.fetch("data", nil) | ||
@metadata = Bolognese::Metadata.new(input: string, from: "citeproc") | ||
else | ||
fail AbstractController::ActionNotFound | ||
end | ||
end | ||
# Non DataCite DOIs i.e. crossref are not supported. | ||
# Requests should go via doi.org to be redirected to the appropriate RA | ||
# content negotiation service | ||
fail AbstractController::ActionNotFound | ||
end | ||
|
||
fail AbstractController::ActionNotFound unless @metadata.exists? | ||
|