Skip to content

Commit

Permalink
error logging for crossref doi creation. datacite/levrieo#56
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jun 23, 2019
1 parent 7a11da8 commit 40fe0b6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ def self.update_datacite_crossref(options={})
response = Event.query(nil, source_id: "datacite-crossref", page: { size: 1, cursor: cursor })
logger.info "[Update] #{response.results.total} events for source datacite-crossref."

# walk through results using cursor
# walk through results using cursor
if response.results.total > 0
while response.results.results.length > 0 do
response = Event.query(nil, source_id: "datacite-crossref", page: { size: size, cursor: cursor })
Expand All @@ -332,6 +332,8 @@ def self.update_datacite_crossref(options={})
end

def self.get_crossref_metadata(id)
logger = Logger.new(STDOUT)

doi = doi_from_url(id)
return {} unless doi.present?

Expand All @@ -341,7 +343,12 @@ def self.get_crossref_metadata(id)
# otherwise store Crossref metadata with DataCite
# using client crossref.citations and DataCite XML
xml = Base64.strict_encode64(id)
Doi.create({ xml: xml, source: "levriero", event: "publish", client_id: "crossref.citations" }, :without_protection => true)
d = Doi.new({ xml: xml, source: "levriero", event: "publish", client_id: "crossref.citations" }, :without_protection => true)
if d.save
logger.info "Record for DOI #{doi} created."
else
logger.warn "[Error for #{doi}]: " + d.errors.inspect
end
end
end

Expand Down

0 comments on commit 40fe0b6

Please sign in to comment.