diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2aab6ede..c7e20ca1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -4,6 +4,9 @@ class ApplicationController < ActionController::Base attr_accessor :authenticity_token + PREFIX_ID_CUL = 'cul-' + PREFIX_ID_LDPD = 'ldpd_' + private # @as_repo_id => repo ID in ArchiveSpace @@ -15,9 +18,10 @@ def validate_repository_code_and_set_repo_id rescue ActiveRecord::RecordNotFound => e Rails.logger.warn(e.message) unless params[:id].blank? - bib_id = params[:id].delete_prefix('ldpd_') - Rails.logger.warn("redirect to CLIO with Bib ID #{bib_id}") - redirect_to CONFIG[:clio_redirect_url] + bib_id + clio_id = params[:id].delete_prefix(PREFIX_ID_LDPD) + clio_id.sub!(PREFIX_ID_CUL, '') + Rails.logger.warn("redirect to CLIO with Bib ID #{clio_id}") + redirect_to (CONFIG[:clio_redirect_url] + clio_id), allow_other_host: true else Rails.logger.warn("no Bib ID in url") redirect_to '/' diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index a9e66071..173b1f43 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -376,18 +376,20 @@ class CatalogController < ApplicationController def resolve if params[:id].present? - solr_id = (params[:id] =~ /^\d+$/) ? "ldpd_#{params[:id]}" : params[:id] + solr_id = (params[:id] =~ /^\d+$/) ? "#{PREFIX_ID_CUL}#{params[:id]}" : params[:id].dup + solr_id.sub!(PREFIX_ID_LDPD, PREFIX_ID_CUL) + clio_id = solr_id.delete_prefix(PREFIX_ID_CUL) if solr_id =~ /cul\-/ begin @document = search_service.fetch(solr_id) repo_id = @document&.fetch(:repository_id_ssi, nil) if repo_id redirect_to repository_finding_aid_path(repository_id: repo_id, id: solr_id) else - redirect_to CONFIG[:clio_redirect_url] + params[:id].delete_prefix('ldpd_') + redirect_to (CONFIG[:clio_redirect_url] + clio_id), allow_other_host: true end rescue Blacklight::Exceptions::RecordNotFound Rails.logger.warn("Record not found: #{solr_id}") - redirect_url = (CONFIG[:clio_redirect_url] + solr_id.delete_prefix('ldpd_')) if (solr_id =~ /^ldpd_\d+$/) + redirect_url = (CONFIG[:clio_redirect_url] + clio_id) if clio_id if redirect_url redirect_to(redirect_url, allow_other_host: true) else diff --git a/app/values/aeon_local_request.rb b/app/values/aeon_local_request.rb index ad7006d0..b43dea44 100644 --- a/app/values/aeon_local_request.rb +++ b/app/values/aeon_local_request.rb @@ -43,7 +43,7 @@ def reference_number # but we don't currently send Barnard items to Aeon so we don't need to worry about # handling that case. We can always assume that all relevant records have an # extractable bibid. - match_data = @solr_document['id'].match(/ldpd_(.+)_aspace.*/); + match_data = @solr_document['id'].match(/cul-(.+)_aspace.*/); match_data.nil? ? nil : match_data[1] end diff --git a/lib/ead/traject/ead2_config.rb b/lib/ead/traject/ead2_config.rb index 6c9e023f..3c21d454 100644 --- a/lib/ead/traject/ead2_config.rb +++ b/lib/ead/traject/ead2_config.rb @@ -73,8 +73,14 @@ def eadid_from_url_or_text(field_name) ead_url = record.xpath('/ead/eadheader/eadid/@url').first ead_id = /ldpd_(\d+)\/?/.match(ead_url.to_s)&.[](1) end + ead_id.sub!(/^ldpd_/,'') + ead_id.gsub!(/[^A-Za-z0-9]/,'-') if ead_id - accumulator.concat ["ldpd_#{ead_id}"] + if ead_id =~ /^\d/ + accumulator.concat ["cul-#{ead_id}"] + else + accumulator.concat [ead_id] + end else logger.warn "no id found; skipping #{settings['command_line.filename']}" context.skip! diff --git a/lib/tasks/acfa.rake b/lib/tasks/acfa.rake index d7aeb640..b8ed8065 100644 --- a/lib/tasks/acfa.rake +++ b/lib/tasks/acfa.rake @@ -27,10 +27,10 @@ namespace :acfa do solr_url = ENV.fetch('SOLR_URL', Blacklight.default_index.connection.base_uri) ead_dir = CONFIG[:ead_cache_dir] puts "Seeding index for #{rails_env}" - bib_pattern = /ldpd_(\d+).xml$/ - bib = ENV['BIB'] ? "ldpd_#{ENV['BIB']}" : '*' + bib_pattern = /cul-(\d+).xml$/ + bib = ENV['BIB'] ? "cul-#{ENV['BIB']}" : '*' filename_pattern = ENV['PATTERN'] - filename_pattern ||= (ENV['CLIO_STUBS'].to_s =~ /true/i) ? "clio_ead_ldpd_#{bib}.xml" : "as_ead_#{bib}.xml" + filename_pattern ||= (ENV['CLIO_STUBS'].to_s =~ /true/i) ? "clio_ead_cul-#{bib}.xml" : "as_ead_#{bib}.xml" indexed = 0 glob_pattern = File.join(ead_dir, filename_pattern) puts "Seeding index with as_ead data from #{glob_pattern}..." diff --git a/spec/controllers/catalog_controller_spec.rb b/spec/controllers/catalog_controller_spec.rb index a712d7f0..10bba679 100644 --- a/spec/controllers/catalog_controller_spec.rb +++ b/spec/controllers/catalog_controller_spec.rb @@ -5,7 +5,7 @@ describe "GET #resolve" do let(:id) { '123456789' } let(:bib_id) { '123456789' } - let(:solr_id) { 'ldpd_123456789' } + let(:solr_id) { 'cul-123456789' } let(:repository_id) { 'nnc' } let(:search_service) { instance_double(Blacklight::SearchService) } let(:solr_doc) { {id: solr_id, repository_id_ssi: repository_id} } @@ -38,7 +38,7 @@ end end context "id has ldpd prefix" do - let(:id) { 'ldpd_123456789' } + let(:id) { 'cul-123456789' } it "redirects to finding aid" do expect(controller).to receive(:redirect_to).with(finding_aid_url).and_call_original get :resolve, params: { id: id } diff --git a/spec/ead/traject/ead2_config_spec.rb b/spec/ead/traject/ead2_config_spec.rb index ca736147..344c7c42 100644 --- a/spec/ead/traject/ead2_config_spec.rb +++ b/spec/ead/traject/ead2_config_spec.rb @@ -23,7 +23,7 @@ end let(:index_document) { subject.map_record(record).with_indifferent_access } describe 'eadid' do - let(:expected_value) { 'ldpd_1234567' } + let(:expected_value) { 'cul-1234567' } context 'is given in /ead/archdesc/unitid[1]/text()' do let(:fixture_path) { File.join(file_fixture_path, 'ead/test_eadid/from_unitid.xml') } it { expect(index_document).not_to be_nil } @@ -44,6 +44,14 @@ it { expect(index_document[:id]).to eql [expected_value] } it { expect(index_document[:ead_ssi]).to eql [expected_value] } end + + context 'is a dot-delimited ID' do + let(:expected_value) { 'BC20-09' } + let(:fixture_path) { File.join(file_fixture_path, 'ead/test_eadid/from_nynybaw_ead.xml') } + it { expect(index_document).not_to be_nil } + it { expect(index_document[:id]).to eql [expected_value] } + it { expect(index_document[:ead_ssi]).to eql [expected_value] } + end end describe 'date_range_* indexing' do context 'has bulk range' do diff --git a/spec/fixtures/ead/test_eadid/from_nynybaw_ead.xml b/spec/fixtures/ead/test_eadid/from_nynybaw_ead.xml new file mode 100644 index 00000000..59e95004 --- /dev/null +++ b/spec/fixtures/ead/test_eadid/from_nynybaw_ead.xml @@ -0,0 +1,16 @@ + +BC20.09Guide to Alice Duer Miller Papers + BC20.09Shannon O'NeillBarnard Archives and Special Collections

© 2015

3009 BroadwayNew York, NY 10027archives@barnard.eduURL:
This finding aid was produced using ArchivesSpace on 2024-03-01 18:18:26 -0500.EnglishDescribing Archives: A Content Standard
+ + + Barnard Archives and Special Collections + + Alice Duer Miller Papers + + Miller, Alice Duer, 1874-1942 + + BC20.09 + /repositories/2/resources/355 + + +
\ No newline at end of file diff --git a/spec/models/solr_document_spec.rb b/spec/models/solr_document_spec.rb index a02ac2c4..599f6c9e 100644 --- a/spec/models/solr_document_spec.rb +++ b/spec/models/solr_document_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe SolrDocument, type: :model do - let(:id) { "ldpd_#{bibid}_aspace_abcdefabcdefabcdefabcdefabcdefab" } + let(:id) { "cul-#{bibid}_aspace_abcdefabcdefabcdefabcdefabcdefab" } let(:bibid) { '12345678' } let(:title_ssm) { ['Great Title'] } let(:creator_ssim) { ['Great Author'] } diff --git a/spec/requests/api/v1/index/delete_ead_spec.rb b/spec/requests/api/v1/index/delete_ead_spec.rb index 000ef4b7..99334fc0 100644 --- a/spec/requests/api/v1/index/delete_ead_spec.rb +++ b/spec/requests/api/v1/index/delete_ead_spec.rb @@ -12,7 +12,7 @@ end describe "with authentication" do - let(:bibids) { ['ldpd_7746709', 'ldpd_8972723'] } + let(:bibids) { ['cul-7746709', 'cul-8972723'] } let(:delete_ead_job_double) { double(DeleteEadJob) } before do allow(DeleteEadJob).to receive(:new).and_return(delete_ead_job_double) diff --git a/spec/requests/api/v1/index/index_ead_spec.rb b/spec/requests/api/v1/index/index_ead_spec.rb index f50e84aa..229377c7 100644 --- a/spec/requests/api/v1/index/index_ead_spec.rb +++ b/spec/requests/api/v1/index/index_ead_spec.rb @@ -12,7 +12,7 @@ end describe "with authentication" do - let(:bibids) { ['ldpd_7746709', 'ldpd_8972723'] } + let(:bibids) { ['cul-7746709', 'cul-8972723'] } let(:index_ead_job_double) { double(IndexEadJob) } before do allow(IndexEadJob).to receive(:new).and_return(index_ead_job_double) diff --git a/spec/values/aeon_local_request_spec.rb b/spec/values/aeon_local_request_spec.rb index 5c2227de..4e327bda 100644 --- a/spec/values/aeon_local_request_spec.rb +++ b/spec/values/aeon_local_request_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' RSpec.describe AeonLocalRequest do - let(:id) { "ldpd_#{bibid}_aspace_abcdefabcdefabcdefabcdefabcdefab" } + let(:id) { "cul-#{bibid}_aspace_abcdefabcdefabcdefabcdefabcdefab" } let(:bibid) { '12345678' } let(:collection_ssim) { ['Great Collection Name'] } let(:title_ssm) { ['Great Title'] } diff --git a/spec/views/catalog/_document.atom.builder_spec.rb b/spec/views/catalog/_document.atom.builder_spec.rb index b39b96c3..ea5c1222 100644 --- a/spec/views/catalog/_document.atom.builder_spec.rb +++ b/spec/views/catalog/_document.atom.builder_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe "catalog/_document.atom.builder", type: :view do - let(:finding_aid_id) { 'ldpd_ABCDEFG' } + let(:finding_aid_id) { 'cul-ABCDEFG' } let(:repository_id) { 'nnc' } let(:aspace_base_repository_id) { 'nynybaw' } let(:arclight_params) { {_root_: finding_aid_id, repository_id_ssi: repository_id, level_ssim: ['File'], component_level_isim: [3]} } diff --git a/spec/views/catalog/_document.rss.builder_spec.rb b/spec/views/catalog/_document.rss.builder_spec.rb index badb029b..45223569 100644 --- a/spec/views/catalog/_document.rss.builder_spec.rb +++ b/spec/views/catalog/_document.rss.builder_spec.rb @@ -4,7 +4,7 @@ require 'rails_helper' RSpec.describe "catalog/_document.rss.builder", type: :view do - let(:finding_aid_id) { 'ldpd_ABCDEFG' } + let(:finding_aid_id) { 'cul-ABCDEFG' } let(:repository_id) { 'nnc' } let(:aspace_base_repository_id) { 'nynybaw' } let(:arclight_params) { {_root_: finding_aid_id, repository_id_ssi: repository_id, level_ssim: ['File'], component_level_isim: [3]} } diff --git a/spec/views/catalog/index.json.builder_spec.rb b/spec/views/catalog/index.json.builder_spec.rb index 8366e4c5..68f97489 100644 --- a/spec/views/catalog/index.json.builder_spec.rb +++ b/spec/views/catalog/index.json.builder_spec.rb @@ -3,7 +3,7 @@ RSpec.describe "catalog/index.json", type: :view do let(:response) { instance_double(Blacklight::Solr::Response, documents: docs, prev_page: nil, next_page: 2, total_pages: 3) } - let(:finding_aid_id) { 'ldpd_ABCDEFG' } + let(:finding_aid_id) { 'cul-ABCDEFG' } let(:repository_id) { 'nnc' } let(:aspace_base_repository_id) { 'nynybaw' } let(:arclight_params) { {_root_: finding_aid_id, repository_id_ssi: repository_id, level_ssim: ['File'], component_level_isim: [3]} } @@ -74,12 +74,12 @@ it "serializes a local collection" do expect(response_data).to include( { - id: 'ldpd_ABCDEFG', + id: finding_aid_id, type: 'Collection', attributes: { title: 'CUL Collection' }, - links: { self: '/archives/ldpd_ABCDEFG' } + links: { self: "/archives/#{finding_aid_id}" } } ) end diff --git a/test/fixtures/files/fa_lists/nnc-a_fa_list.html b/test/fixtures/files/fa_lists/nnc-a_fa_list.html index 6f9cf44e..647a21d3 100644 --- a/test/fixtures/files/fa_lists/nnc-a_fa_list.html +++ b/test/fixtures/files/fa_lists/nnc-a_fa_list.html @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/test/fixtures/files/fa_lists/nnc-ea_fa_list.html b/test/fixtures/files/fa_lists/nnc-ea_fa_list.html index 5e0f78a7..e45febd3 100644 --- a/test/fixtures/files/fa_lists/nnc-ea_fa_list.html +++ b/test/fixtures/files/fa_lists/nnc-ea_fa_list.html @@ -1,3 +1,3 @@ \ No newline at end of file diff --git a/test/fixtures/files/fa_lists/nnc-rb_fa_list.html b/test/fixtures/files/fa_lists/nnc-rb_fa_list.html index 1f08bd58..870cad7b 100644 --- a/test/fixtures/files/fa_lists/nnc-rb_fa_list.html +++ b/test/fixtures/files/fa_lists/nnc-rb_fa_list.html @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/test/fixtures/files/fa_lists/nnc-ut_fa_list.html b/test/fixtures/files/fa_lists/nnc-ut_fa_list.html index e94d9ffc..82b85b3b 100644 --- a/test/fixtures/files/fa_lists/nnc-ut_fa_list.html +++ b/test/fixtures/files/fa_lists/nnc-ut_fa_list.html @@ -1,3 +1,3 @@ \ No newline at end of file