diff --git a/app/controllers/oaisys/pmh_controller.rb b/app/controllers/oaisys/pmh_controller.rb index e95e6c6..78e8736 100644 --- a/app/controllers/oaisys/pmh_controller.rb +++ b/app/controllers/oaisys/pmh_controller.rb @@ -74,7 +74,7 @@ def list_metadata_formats end render :list_metadata_formats, - formats: :xml, locals: { formats: formats, parameters: parameters } + formats: :xml, locals: { formats: formats, parameters: prep_identifiers(parameters) } end def list_records @@ -118,7 +118,7 @@ def get_record raise Oaisys::IdDoesNotExistError.new(parameters: params) if obj.blank? - render :get_record, formats: :xml, locals: { item: obj, metadata_format: metadata_format } + render :get_record, formats: :xml, locals: { item: obj, parameters: prep_identifiers(params) } end # rubocop:enable Naming/AccessorMethodName @@ -218,7 +218,11 @@ def public_items_for_metadata_format(verb:, format:, page:, restricted_to_set: n model = model.public_items.belongs_to_path(restricted_to_set.tr(':', '/')) if restricted_to_set.present? model = model.updated_on_or_after(from_date) if from_date.present? - model = model.updated_on_or_before(until_date) if until_date.present? + + if until_date.present? + just_after_until_date = (until_date.to_time + 1.second).utc.xmlschema + model = model.updated_before(just_after_until_date) + end items_per_request = Oaisys::Engine.config.items_per_request model = model.page(page).per(items_per_request) @@ -269,4 +273,9 @@ def check_resumption_token(model, resumption_token_provided, total_count, parame raise Oaisys::BadResumptionTokenError.new, I18n.t('error_messages.resumption_token_invalid') end + def prep_identifiers(parameters) + parameters['identifier'].prepend('oai:era.library.ualberta.ca:') if parameters['identifier'].present? + parameters + end + end diff --git a/app/views/oaisys/pmh/get_record.xml.builder b/app/views/oaisys/pmh/get_record.xml.builder index c442e76..0c7b316 100644 --- a/app/views/oaisys/pmh/get_record.xml.builder +++ b/app/views/oaisys/pmh/get_record.xml.builder @@ -19,18 +19,17 @@ xml.push_deferred_attribute('xmlns:dc': 'http://purl.org/dc/elements/1.1/', 'http://www.ndltd.org/standards/metadata/etdms/1-0/etdms.xsd '\ 'http://www.w3.org/2005/Atom') -xml.tag!('request', 'https://era.library.ualberta.ca/oai', verb: 'GetRecord', metadataPrefix: metadata_format, - identifier: item.id) +xml.tag!('request', parameters, 'https://era.library.ualberta.ca/oai') xml.GetRecord do |get_record| get_record.record do |record| record.header do |header| - header.identifier "oai:era.library.ualberta.ca:#{item.id}" - header.datestamp item.updated_at + header.identifier parameters[:identifier] + header.datestamp item.updated_at.utc.xmlschema item.member_of_paths.each { |path| header.setSpec path.tr('/', ':') } end record.metadata do |metadata_xml| - item.serialize_metadata(format: metadata_format, into_document: metadata_xml) + item.serialize_metadata(format: parameters[:metadataPrefix], into_document: metadata_xml) end end end diff --git a/app/views/oaisys/pmh/list_records.xml.builder b/app/views/oaisys/pmh/list_records.xml.builder index 5cc1797..535b580 100644 --- a/app/views/oaisys/pmh/list_records.xml.builder +++ b/app/views/oaisys/pmh/list_records.xml.builder @@ -26,7 +26,7 @@ xml.ListRecords do |list_records| list_records.record do |record| record.header do |header| header.identifier "oai:era.library.ualberta.ca:#{item.id}" - header.datestamp item.updated_at + header.datestamp item.updated_at.utc.xmlschema item.member_of_paths.each { |path| header.setSpec path.tr('/', ':') } end record.metadata do |metadata_xml|