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 @@
+
+