bulkrax 9.5.2 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +49 -0
- data/app/controllers/bulkrax/application_controller.rb +83 -0
- data/app/controllers/bulkrax/entries_controller.rb +16 -13
- data/app/controllers/bulkrax/exporters_controller.rb +21 -25
- data/app/controllers/bulkrax/guided_imports_controller.rb +4 -8
- data/app/controllers/bulkrax/importers_controller.rb +43 -87
- data/app/controllers/concerns/bulkrax/datatables_behavior.rb +18 -12
- data/app/controllers/concerns/bulkrax/importer_file_handler.rb +9 -55
- data/app/factories/bulkrax/object_factory.rb +2 -2
- data/app/factories/bulkrax/valkyrie_object_factory.rb +29 -17
- data/app/helpers/bulkrax/validation_helper.rb +1 -1
- data/app/jobs/bulkrax/create_relationships_job.rb +1 -1
- data/app/jobs/bulkrax/download_cloud_file_job.rb +21 -156
- data/app/jobs/bulkrax/import_collection_job.rb +9 -2
- data/app/matchers/bulkrax/application_matcher.rb +5 -2
- data/app/models/bulkrax/csv_entry.rb +1 -1
- data/app/models/bulkrax/current.rb +7 -0
- data/app/models/bulkrax/export_scope.rb +21 -0
- data/app/models/bulkrax/exporter.rb +2 -2
- data/app/models/bulkrax/importer.rb +1 -1
- data/app/models/concerns/bulkrax/ability_behavior.rb +139 -0
- data/app/models/concerns/bulkrax/has_matchers.rb +1 -1
- data/app/models/concerns/bulkrax/import_behavior.rb +3 -3
- data/app/parsers/bulkrax/application_parser.rb +10 -10
- data/app/parsers/bulkrax/bagit_parser.rb +3 -10
- data/app/parsers/bulkrax/csv_parser.rb +28 -58
- data/app/parsers/bulkrax/oai_dc_parser.rb +1 -1
- data/app/parsers/bulkrax/parser_export_record_set.rb +26 -8
- data/app/parsers/concerns/bulkrax/csv_parser/csv_template_generation.rb +1 -1
- data/app/parsers/concerns/bulkrax/csv_parser/csv_validation.rb +1 -2
- data/app/parsers/concerns/bulkrax/csv_parser/csv_validation_helpers.rb +18 -1
- data/app/parsers/concerns/bulkrax/csv_parser/csv_validation_hierarchy.rb +2 -2
- data/app/search_builders/bulkrax/export_search_builder.rb +9 -0
- data/app/services/bulkrax/csv_template/column_builder.rb +2 -2
- data/app/services/bulkrax/csv_template/mapping_manager.rb +9 -7
- data/app/services/bulkrax/csv_template/schema_analyzer.rb +1 -5
- data/config/locales/bulkrax.en.yml +0 -2
- data/lib/bulkrax/engine.rb +1 -1
- data/lib/bulkrax/version.rb +1 -1
- data/lib/bulkrax.rb +76 -11
- data/lib/generators/bulkrax/install_generator.rb +22 -10
- data/lib/generators/bulkrax/templates/config/initializers/bulkrax.rb +1 -1
- metadata +32 -34
- data/app/errors/bulkrax/unsafe_cloud_source_error.rb +0 -11
- data/app/errors/bulkrax/unsafe_path_error.rb +0 -8
- data/app/parsers/bulkrax/application_parser.rb.orig +0 -545
- data/app/services/bulkrax/cloud_source_validator.rb +0 -123
- data/app/services/bulkrax/safe_path.rb +0 -129
- data/lib/wings/custom_queries/find_by_source_identifier.rb +0 -41
|
@@ -71,7 +71,7 @@ module Bulkrax
|
|
|
71
71
|
metadata = {
|
|
72
72
|
visibility: 'open'
|
|
73
73
|
}
|
|
74
|
-
metadata[:collection_type_gid] = Hyrax::CollectionType.find_or_create_default_collection_type.to_global_id.to_s if
|
|
74
|
+
metadata[:collection_type_gid] = Hyrax::CollectionType.find_or_create_default_collection_type.to_global_id.to_s if Bulkrax.hyrax_loaded?
|
|
75
75
|
|
|
76
76
|
collections.each_with_index do |set, index|
|
|
77
77
|
next unless collection_name == 'all' || collection_name == set.spec
|
|
@@ -120,7 +120,10 @@ module Bulkrax
|
|
|
120
120
|
#
|
|
121
121
|
# No sense attempting to query for more than the limit.
|
|
122
122
|
def query_kwargs
|
|
123
|
-
{ fl: "id,#{Bulkrax.solr_key_for_member_file_ids}", method: :post, rows: row_limit }
|
|
123
|
+
base = { fl: "id,#{Bulkrax.solr_key_for_member_file_ids}", method: :post, rows: row_limit }
|
|
124
|
+
filters = permission_filters
|
|
125
|
+
return base if filters.empty?
|
|
126
|
+
base.merge(fq: filters)
|
|
124
127
|
end
|
|
125
128
|
|
|
126
129
|
# If we have a limit, we need not query beyond that limit
|
|
@@ -175,10 +178,25 @@ module Bulkrax
|
|
|
175
178
|
@file_sets ||= ParserExportRecordSet.in_batches(candidate_file_set_ids) do |batch_of_ids|
|
|
176
179
|
fsq = "has_model_ssim:\"#{Bulkrax.file_model_internal_resource.demodulize}\" AND id:(\"" + batch_of_ids.join('" OR "') + "\")"
|
|
177
180
|
fsq += extra_filters if extra_filters.present?
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
)
|
|
181
|
+
fq = permission_filters
|
|
182
|
+
kwargs = { fl: "id", method: :post, rows: batch_of_ids.size }
|
|
183
|
+
kwargs[:fq] = fq unless fq.empty?
|
|
184
|
+
Bulkrax.object_factory.query(fsq, **kwargs)
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
def exporting_user
|
|
189
|
+
importerexporter.user || Bulkrax.fallback_user_for_importer_exporter_processing
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
def permission_filters
|
|
193
|
+
@permission_filters ||= begin
|
|
194
|
+
ability = Ability.new(exporting_user)
|
|
195
|
+
return [] if ability.can_admin_exporters?
|
|
196
|
+
|
|
197
|
+
scope = Bulkrax::ExportScope.new(ability)
|
|
198
|
+
builder = Bulkrax::ExportSearchBuilder.new(scope)
|
|
199
|
+
builder.to_h.fetch(:fq, [])
|
|
182
200
|
end
|
|
183
201
|
end
|
|
184
202
|
|
|
@@ -246,7 +264,7 @@ module Bulkrax
|
|
|
246
264
|
Bulkrax.object_factory.query(
|
|
247
265
|
extra_filters.to_s,
|
|
248
266
|
**query_kwargs.merge(
|
|
249
|
-
fq: [
|
|
267
|
+
fq: (query_kwargs[:fq] || []) + [
|
|
250
268
|
%(#{solr_name(work_identifier)}:("#{ids.join('" OR "')}")),
|
|
251
269
|
"has_model_ssim:(#{Bulkrax.curation_concern_internal_resources.join(' OR ')})"
|
|
252
270
|
],
|
|
@@ -261,7 +279,7 @@ module Bulkrax
|
|
|
261
279
|
Bulkrax.object_factory.query(
|
|
262
280
|
"has_model_ssim:#{Bulkrax.collection_model_internal_resource} #{extra_filters}",
|
|
263
281
|
**query_kwargs.merge(
|
|
264
|
-
fq: [
|
|
282
|
+
fq: (query_kwargs[:fq] || []) + [
|
|
265
283
|
%(#{solr_name(work_identifier)}:("#{ids.join('" OR "')}")),
|
|
266
284
|
"has_model_ssim:#{Bulkrax.collection_model_internal_resource}"
|
|
267
285
|
],
|
|
@@ -280,7 +298,7 @@ module Bulkrax
|
|
|
280
298
|
Bulkrax.object_factory.query(
|
|
281
299
|
extra_filters,
|
|
282
300
|
**query_kwargs.merge(
|
|
283
|
-
fq: [
|
|
301
|
+
fq: (query_kwargs[:fq] || []) + [
|
|
284
302
|
%(#{solr_name(work_identifier)}:("#{ids.join('" OR "')}")),
|
|
285
303
|
"has_model_ssim:#{Bulkrax.file_model_internal_resource}"
|
|
286
304
|
],
|
|
@@ -14,7 +14,7 @@ module Bulkrax
|
|
|
14
14
|
# @param args [Hash] Additional arguments passed to output method (e.g., file_path)
|
|
15
15
|
# @return [String] File path (for 'file' output) or CSV string (for 'csv_string' output)
|
|
16
16
|
def generate_template(models: [], output: 'file', admin_set_id: nil, **args)
|
|
17
|
-
raise NameError, "Hyrax is not defined" unless
|
|
17
|
+
raise NameError, "Hyrax is not defined" unless Bulkrax.hyrax_loaded?
|
|
18
18
|
TemplateContext.new(models: models, admin_set_id: admin_set_id).send("to_#{output}", **args)
|
|
19
19
|
end
|
|
20
20
|
end
|
|
@@ -71,8 +71,7 @@ module Bulkrax
|
|
|
71
71
|
file_key = resolve_validation_key(mapping_manager, key: 'file', default: :file)
|
|
72
72
|
|
|
73
73
|
csv_data = parse_validation_rows(raw_csv, source_id_key, parent_key, children_key, file_key)
|
|
74
|
-
all_models = csv_data
|
|
75
|
-
all_models |= [Bulkrax.default_work_type] if Bulkrax.default_work_type.present?
|
|
74
|
+
all_models = models_to_validate(csv_data, headers)
|
|
76
75
|
field_analyzer = CsvTemplate::FieldAnalyzer.new(mappings, admin_set_id)
|
|
77
76
|
field_metadata = build_validation_field_metadata(all_models, field_analyzer)
|
|
78
77
|
|
|
@@ -64,7 +64,7 @@ module Bulkrax
|
|
|
64
64
|
Rails.logger.error("CsvParser.validate_csv: error building valid headers – #{e.message}")
|
|
65
65
|
standard = %w[model source_identifier parents children file]
|
|
66
66
|
model_fields = field_metadata.values.flat_map { |m| m[:properties] }
|
|
67
|
-
|
|
67
|
+
model_fields = model_fields.map { |prop| mapping_manager.key_to_mapped_column(prop) }
|
|
68
68
|
(standard + model_fields).uniq
|
|
69
69
|
end
|
|
70
70
|
|
|
@@ -129,6 +129,23 @@ module Bulkrax
|
|
|
129
129
|
all_models.each { |model| missing_required << { model: model, field: source_id_key.to_s } }
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
+
# Adding the default work type unconditionally makes every sheet answer
|
|
133
|
+
# for that model's required fields, so a collection-only sheet gets asked
|
|
134
|
+
# for properties belonging to a work type it never mentions.
|
|
135
|
+
def models_to_validate(csv_data, headers)
|
|
136
|
+
row_models = csv_data.map { |r| r[:model].to_s }.reject(&:blank?).uniq
|
|
137
|
+
return row_models if Bulkrax.default_work_type.blank?
|
|
138
|
+
return row_models unless default_work_type_needed?(csv_data, headers)
|
|
139
|
+
|
|
140
|
+
row_models | [Bulkrax.default_work_type]
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def default_work_type_needed?(csv_data, headers)
|
|
144
|
+
return true unless headers.map(&:to_s).include?('model')
|
|
145
|
+
|
|
146
|
+
csv_data.empty? || csv_data.any? { |r| r[:model].blank? }
|
|
147
|
+
end
|
|
148
|
+
|
|
132
149
|
# Adds a file-level notice when the model column is absent or every row has a blank
|
|
133
150
|
# model value, indicating that the default work type will be used for all rows.
|
|
134
151
|
# When this notice is present the per-row default_work_type_used warnings are
|
|
@@ -36,9 +36,9 @@ module Bulkrax
|
|
|
36
36
|
model_str = item[:model].to_s
|
|
37
37
|
|
|
38
38
|
opts = { type: nil, find_record: find_record, parent: parent_split_pattern, child: child_split_pattern }
|
|
39
|
-
if
|
|
39
|
+
if Bulkrax.collection_model_name?(model_str)
|
|
40
40
|
collections << build_item_hash(item, child_to_parents, all_ids, opts.merge(type: 'collection'))
|
|
41
|
-
elsif
|
|
41
|
+
elsif Bulkrax.file_model_name?(model_str)
|
|
42
42
|
file_sets << { id: item_id, title: item[:raw_row]['title'] || item_id, type: 'file_set' }
|
|
43
43
|
else
|
|
44
44
|
works << build_item_hash(item, child_to_parents, all_ids, opts.merge(type: 'work'))
|
|
@@ -43,8 +43,8 @@ module Bulkrax
|
|
|
43
43
|
|
|
44
44
|
# When a property is the target of one or more `object:` field mappings,
|
|
45
45
|
# emit each of those mappings' `from:` columns (e.g. redirect_path,
|
|
46
|
-
#
|
|
47
|
-
#
|
|
46
|
+
# redirect_display_url) rather than the bare property name (redirects).
|
|
47
|
+
# Otherwise fall back to the standard 1:1 mapping.
|
|
48
48
|
def columns_for_property(property)
|
|
49
49
|
nested = @service.mapping_manager.object_columns_for(property)
|
|
50
50
|
return nested if nested.any?
|
|
@@ -35,16 +35,18 @@ module Bulkrax
|
|
|
35
35
|
|
|
36
36
|
# Returns the column names that target a given object name via the
|
|
37
37
|
# `object:` field-mapping pattern. The template generator uses this to
|
|
38
|
-
# emit the per-child columns (e.g. redirect_path,
|
|
39
|
-
#
|
|
40
|
-
#
|
|
41
|
-
#
|
|
42
|
-
#
|
|
38
|
+
# emit the per-child columns (e.g. redirect_path, redirect_display_url)
|
|
39
|
+
# instead of the bare property name (redirects). Numbering is
|
|
40
|
+
# intentionally omitted — the template shows the column shape once;
|
|
41
|
+
# CSV rows can repeat the column with numeric suffixes (e.g.
|
|
42
|
+
# redirect_path_1, redirect_path_2) at import time.
|
|
43
|
+
# An import accepts every `from:` alias, but offering them all here would
|
|
44
|
+
# put two columns for the same field on the template.
|
|
43
45
|
def object_columns_for(object_name)
|
|
44
46
|
@mappings
|
|
45
47
|
.select { |_k, v| v.is_a?(Hash) && v["object"] == object_name }
|
|
46
|
-
.
|
|
47
|
-
.
|
|
48
|
+
.keys
|
|
49
|
+
.map { |key| key_to_mapped_column(key) }
|
|
48
50
|
.uniq
|
|
49
51
|
end
|
|
50
52
|
|
|
@@ -36,11 +36,7 @@ module Bulkrax
|
|
|
36
36
|
def load_schema
|
|
37
37
|
return nil unless @klass.respond_to?(:schema)
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
Hyrax.schema_for(klass: @klass, admin_set_id: @admin_set_id)
|
|
41
|
-
else
|
|
42
|
-
@klass.new.singleton_class.schema || @klass.schema
|
|
43
|
-
end
|
|
39
|
+
Bulkrax::ValkyrieObjectFactory.cached_schema_for(klass: @klass, admin_set_id: @admin_set_id)
|
|
44
40
|
rescue StandardError
|
|
45
41
|
nil
|
|
46
42
|
end
|
|
@@ -91,8 +91,6 @@ en:
|
|
|
91
91
|
public: Public
|
|
92
92
|
browse_everything:
|
|
93
93
|
add_cloud_files: Add Cloud Files
|
|
94
|
-
errors:
|
|
95
|
-
missing_destination_context: This cloud file download is missing required destination information and can no longer be safely processed. Please re-select the file and try the import again.
|
|
96
94
|
csv:
|
|
97
95
|
add_csv_to_import: 'Add CSV or ZIP File to Import:'
|
|
98
96
|
add_files_hint: Choose files to upload. The filenames must be unique, and the filenames must be referenced in a column called 'file' in the accompanying CSV file.
|
data/lib/bulkrax/engine.rb
CHANGED
|
@@ -26,7 +26,7 @@ module Bulkrax
|
|
|
26
26
|
config.after_initialize do
|
|
27
27
|
# We want to ensure that Bulkrax is earlier in the lookup for view_paths than Hyrax. That is
|
|
28
28
|
# we favor view in Bulkrax over those in Hyrax.
|
|
29
|
-
if
|
|
29
|
+
if Bulkrax.hyrax_loaded?
|
|
30
30
|
my_engine_root = Bulkrax::Engine.root.to_s
|
|
31
31
|
hyrax_engine_root = Hyrax::Engine.root.to_s
|
|
32
32
|
paths = ActionController::Base.view_paths.collect(&:to_s)
|
data/lib/bulkrax/version.rb
CHANGED
data/lib/bulkrax.rb
CHANGED
|
@@ -6,6 +6,7 @@ require 'active_support/all'
|
|
|
6
6
|
|
|
7
7
|
require 'coderay'
|
|
8
8
|
require 'csv'
|
|
9
|
+
require 'deprecation'
|
|
9
10
|
require 'denormalize_fields'
|
|
10
11
|
require 'erb'
|
|
11
12
|
require 'iso8601'
|
|
@@ -13,11 +14,8 @@ require 'language_list'
|
|
|
13
14
|
require 'marcel'
|
|
14
15
|
require 'nokogiri'
|
|
15
16
|
require 'ostruct'
|
|
16
|
-
require 'ssrf_filter'
|
|
17
17
|
require 'zip'
|
|
18
18
|
|
|
19
|
-
require 'wings/custom_queries/find_by_source_identifier'
|
|
20
|
-
|
|
21
19
|
def conditional_require(gem_name)
|
|
22
20
|
require gem_name
|
|
23
21
|
rescue LoadError
|
|
@@ -32,6 +30,10 @@ module Bulkrax
|
|
|
32
30
|
extend self # rubocop:disable Style/ModuleFunction
|
|
33
31
|
extend Forwardable
|
|
34
32
|
|
|
33
|
+
def hyrax_loaded?
|
|
34
|
+
defined?(::Hyrax::Engine) ? true : false
|
|
35
|
+
end
|
|
36
|
+
|
|
35
37
|
##
|
|
36
38
|
# @api public
|
|
37
39
|
class Configuration
|
|
@@ -86,7 +88,7 @@ module Bulkrax
|
|
|
86
88
|
def solr_key_for_member_file_ids
|
|
87
89
|
return @solr_key_for_member_file_ids if @solr_key_for_member_file_ids.present?
|
|
88
90
|
|
|
89
|
-
return "member_ids_ssim" if
|
|
91
|
+
return "member_ids_ssim" if Bulkrax.hyrax_loaded?
|
|
90
92
|
|
|
91
93
|
"#{file_model_class.name.to_s.underscore}_ids_ssim"
|
|
92
94
|
end
|
|
@@ -111,10 +113,13 @@ module Bulkrax
|
|
|
111
113
|
end
|
|
112
114
|
|
|
113
115
|
def collection_model_class
|
|
114
|
-
@collection_model_class ||= Collection if
|
|
116
|
+
@collection_model_class ||= Collection if Bulkrax.hyrax_loaded?
|
|
115
117
|
end
|
|
116
118
|
|
|
117
|
-
|
|
119
|
+
def collection_model_class=(klass)
|
|
120
|
+
@collection_model_names = nil
|
|
121
|
+
@collection_model_class = klass
|
|
122
|
+
end
|
|
118
123
|
|
|
119
124
|
def collection_model_internal_resource
|
|
120
125
|
# WARN: Using #try on :internal_resource can yield unexpected results.
|
|
@@ -130,11 +135,30 @@ module Bulkrax
|
|
|
130
135
|
instance.respond_to?(:internal_resource) ? instance.internal_resource : collection_model_class.to_s
|
|
131
136
|
end
|
|
132
137
|
|
|
138
|
+
# A sheet written against either side of a Wings pair has to import, since
|
|
139
|
+
# both names resolve to the same object.
|
|
140
|
+
def collection_model_names
|
|
141
|
+
@collection_model_names ||=
|
|
142
|
+
model_names_for(collection_model_class, twin: curation_concern_twin_for(collection_model_class))
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
attr_writer :collection_model_names
|
|
146
|
+
|
|
147
|
+
def collection_model_name?(model_name)
|
|
148
|
+
name = model_name.to_s.strip
|
|
149
|
+
return false if name.empty?
|
|
150
|
+
|
|
151
|
+
collection_model_names.any? { |known| name.casecmp(known).zero? }
|
|
152
|
+
end
|
|
153
|
+
|
|
133
154
|
def file_model_class
|
|
134
|
-
@file_model_class ||=
|
|
155
|
+
@file_model_class ||= Bulkrax.hyrax_loaded? ? ::FileSet : File
|
|
135
156
|
end
|
|
136
157
|
|
|
137
|
-
|
|
158
|
+
def file_model_class=(klass)
|
|
159
|
+
@file_model_names = nil
|
|
160
|
+
@file_model_class = klass
|
|
161
|
+
end
|
|
138
162
|
|
|
139
163
|
def file_model_internal_resource
|
|
140
164
|
# WARN: Using #try on :internal_resource can yield unexpected results.
|
|
@@ -150,8 +174,43 @@ module Bulkrax
|
|
|
150
174
|
instance.respond_to?(:internal_resource) ? instance.internal_resource : file_model_class.to_s
|
|
151
175
|
end
|
|
152
176
|
|
|
177
|
+
# As #collection_model_names, for file set rows. Wings pairs file sets by
|
|
178
|
+
# namespace rather than a `Resource` suffix: `Wings::ModelRegistry` maps
|
|
179
|
+
# both `FileSet` and `Hyrax::FileSet` onto the same object, so whichever
|
|
180
|
+
# one is configured, the other is its twin.
|
|
181
|
+
def file_model_names
|
|
182
|
+
@file_model_names ||= model_names_for(file_model_class, twin: file_set_twin_for(file_model_class))
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
attr_writer :file_model_names
|
|
186
|
+
|
|
187
|
+
def file_model_name?(model_name)
|
|
188
|
+
name = model_name.to_s.strip
|
|
189
|
+
return false if name.empty?
|
|
190
|
+
|
|
191
|
+
file_model_names.any? { |known| name.casecmp(known).zero? }
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Constantizing is what distinguishes a Wings install from a name that
|
|
195
|
+
# merely looks like one.
|
|
196
|
+
def model_names_for(klass, twin:)
|
|
197
|
+
names = [klass.to_s]
|
|
198
|
+
names << twin.to_s if twin.present? && twin.to_s.safe_constantize
|
|
199
|
+
names.uniq
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
def curation_concern_twin_for(klass)
|
|
203
|
+
name = klass.to_s
|
|
204
|
+
name.end_with?('Resource') ? name.delete_suffix('Resource') : "#{name}Resource"
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
def file_set_twin_for(klass)
|
|
208
|
+
name = klass.to_s
|
|
209
|
+
name.start_with?('Hyrax::') ? name.delete_prefix('Hyrax::') : "Hyrax::#{name}"
|
|
210
|
+
end
|
|
211
|
+
|
|
153
212
|
def curation_concerns
|
|
154
|
-
@curation_concerns ||=
|
|
213
|
+
@curation_concerns ||= Bulkrax.hyrax_loaded? ? ::Hyrax.config.curation_concerns : []
|
|
155
214
|
end
|
|
156
215
|
|
|
157
216
|
attr_writer :curation_concerns
|
|
@@ -177,7 +236,7 @@ module Bulkrax
|
|
|
177
236
|
# @return [String, Proc]
|
|
178
237
|
def ingest_queue_name
|
|
179
238
|
return @ingest_queue_name if @ingest_queue_name.present?
|
|
180
|
-
return Hyrax.config.ingest_queue_name if
|
|
239
|
+
return Hyrax.config.ingest_queue_name if Bulkrax.hyrax_loaded?
|
|
181
240
|
:import
|
|
182
241
|
end
|
|
183
242
|
|
|
@@ -225,6 +284,9 @@ module Bulkrax
|
|
|
225
284
|
:collection_model_class,
|
|
226
285
|
:collection_model_internal_resource,
|
|
227
286
|
:collection_model_class=,
|
|
287
|
+
:collection_model_name?,
|
|
288
|
+
:collection_model_names,
|
|
289
|
+
:collection_model_names=,
|
|
228
290
|
:curation_concerns,
|
|
229
291
|
:curation_concerns=,
|
|
230
292
|
:curation_concern_internal_resources,
|
|
@@ -241,6 +303,9 @@ module Bulkrax
|
|
|
241
303
|
:file_model_class,
|
|
242
304
|
:file_model_class=,
|
|
243
305
|
:file_model_internal_resource,
|
|
306
|
+
:file_model_name?,
|
|
307
|
+
:file_model_names,
|
|
308
|
+
:file_model_names=,
|
|
244
309
|
:fill_in_blank_source_identifiers,
|
|
245
310
|
:fill_in_blank_source_identifiers=,
|
|
246
311
|
:generated_metadata_mapping,
|
|
@@ -434,7 +499,7 @@ module Bulkrax
|
|
|
434
499
|
end
|
|
435
500
|
|
|
436
501
|
def fallback_user_for_importer_exporter_processing
|
|
437
|
-
return User.batch_user if
|
|
502
|
+
return User.batch_user if Bulkrax.hyrax_loaded? && User.respond_to?(:batch_user)
|
|
438
503
|
|
|
439
504
|
raise "We have no fallback user available for Bulkrax.fallback_user_for_importer_exporter_processing"
|
|
440
505
|
end
|
|
@@ -58,18 +58,30 @@ class Bulkrax::InstallGenerator < Rails::Generators::Base
|
|
|
58
58
|
def add_ability
|
|
59
59
|
file = 'app/models/ability.rb'
|
|
60
60
|
file_text = File.read(file)
|
|
61
|
-
|
|
62
|
-
export_line = 'def can_export_works?'
|
|
63
|
-
unless file_text.include?(import_line)
|
|
64
|
-
insert_into_file file, before: /^end/ do
|
|
65
|
-
" def can_import_works?\n can_create_any_work?\n end"
|
|
66
|
-
end
|
|
67
|
-
end
|
|
61
|
+
include_line = 'include Bulkrax::AbilityBehavior'
|
|
68
62
|
|
|
69
63
|
# rubocop:disable Style/GuardClause
|
|
70
|
-
unless file_text.include?(
|
|
71
|
-
insert_into_file file,
|
|
72
|
-
"
|
|
64
|
+
unless file_text.include?(include_line)
|
|
65
|
+
insert_into_file file, after: /include\s+\S+Ability[^\n]*\n/ do
|
|
66
|
+
" include Bulkrax::AbilityBehavior\n" \
|
|
67
|
+
" self.ability_logic += [:bulkrax_default_abilities]\n\n" \
|
|
68
|
+
" # Override Bulkrax::AbilityBehavior methods as needed, for example:\n" \
|
|
69
|
+
" #\n" \
|
|
70
|
+
" # def can_import_works?\n" \
|
|
71
|
+
" # can_create_any_work?\n" \
|
|
72
|
+
" # end\n" \
|
|
73
|
+
" #\n" \
|
|
74
|
+
" # def can_export_works?\n" \
|
|
75
|
+
" # can_create_any_work?\n" \
|
|
76
|
+
" # end\n" \
|
|
77
|
+
" #\n" \
|
|
78
|
+
" # def can_admin_importers?\n" \
|
|
79
|
+
" # current_user.admin?\n" \
|
|
80
|
+
" # end\n" \
|
|
81
|
+
" #\n" \
|
|
82
|
+
" # def can_admin_exporters?\n" \
|
|
83
|
+
" # current_user.admin?\n" \
|
|
84
|
+
" # end\n"
|
|
73
85
|
end
|
|
74
86
|
end
|
|
75
87
|
# rubocop:enable Style/GuardClause
|
|
@@ -83,6 +83,6 @@ end
|
|
|
83
83
|
|
|
84
84
|
# Sidebar for hyrax 3+ support
|
|
85
85
|
# rubocop:disable Style/IfUnlessModifier
|
|
86
|
-
if
|
|
86
|
+
if Bulkrax.hyrax_loaded? && ::Hyrax::DashboardController&.respond_to?(:sidebar_partials)
|
|
87
87
|
Hyrax::DashboardController.sidebar_partials[:repository_content] << "hyrax/dashboard/sidebar/bulkrax_sidebar_additions"
|
|
88
88
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bulkrax
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 10.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Rob Kaufman
|
|
@@ -15,20 +15,20 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 5.
|
|
18
|
+
version: '5.2'
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 8.
|
|
21
|
+
version: 8.2.0
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
requirements:
|
|
26
26
|
- - ">="
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 5.
|
|
28
|
+
version: '5.2'
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
|
-
version: 8.
|
|
31
|
+
version: 8.2.0
|
|
32
32
|
- !ruby/object:Gem::Dependency
|
|
33
33
|
name: bagit
|
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -71,6 +71,20 @@ dependencies:
|
|
|
71
71
|
- - ">="
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
73
|
version: '0'
|
|
74
|
+
- !ruby/object:Gem::Dependency
|
|
75
|
+
name: deprecation
|
|
76
|
+
requirement: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - "~>"
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '1.0'
|
|
81
|
+
type: :runtime
|
|
82
|
+
prerelease: false
|
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
84
|
+
requirements:
|
|
85
|
+
- - "~>"
|
|
86
|
+
- !ruby/object:Gem::Version
|
|
87
|
+
version: '1.0'
|
|
74
88
|
- !ruby/object:Gem::Dependency
|
|
75
89
|
name: marcel
|
|
76
90
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -243,26 +257,6 @@ dependencies:
|
|
|
243
257
|
- - ">="
|
|
244
258
|
- !ruby/object:Gem::Version
|
|
245
259
|
version: '0'
|
|
246
|
-
- !ruby/object:Gem::Dependency
|
|
247
|
-
name: ssrf_filter
|
|
248
|
-
requirement: !ruby/object:Gem::Requirement
|
|
249
|
-
requirements:
|
|
250
|
-
- - ">="
|
|
251
|
-
- !ruby/object:Gem::Version
|
|
252
|
-
version: '1.0'
|
|
253
|
-
- - "<"
|
|
254
|
-
- !ruby/object:Gem::Version
|
|
255
|
-
version: '2.0'
|
|
256
|
-
type: :runtime
|
|
257
|
-
prerelease: false
|
|
258
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
259
|
-
requirements:
|
|
260
|
-
- - ">="
|
|
261
|
-
- !ruby/object:Gem::Version
|
|
262
|
-
version: '1.0'
|
|
263
|
-
- - "<"
|
|
264
|
-
- !ruby/object:Gem::Version
|
|
265
|
-
version: '2.0'
|
|
266
260
|
- !ruby/object:Gem::Dependency
|
|
267
261
|
name: dry-monads
|
|
268
262
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -281,16 +275,22 @@ dependencies:
|
|
|
281
275
|
name: sqlite3
|
|
282
276
|
requirement: !ruby/object:Gem::Requirement
|
|
283
277
|
requirements:
|
|
284
|
-
- - "
|
|
278
|
+
- - ">="
|
|
285
279
|
- !ruby/object:Gem::Version
|
|
286
280
|
version: '1.4'
|
|
281
|
+
- - "<"
|
|
282
|
+
- !ruby/object:Gem::Version
|
|
283
|
+
version: '3'
|
|
287
284
|
type: :development
|
|
288
285
|
prerelease: false
|
|
289
286
|
version_requirements: !ruby/object:Gem::Requirement
|
|
290
287
|
requirements:
|
|
291
|
-
- - "
|
|
288
|
+
- - ">="
|
|
292
289
|
- !ruby/object:Gem::Version
|
|
293
290
|
version: '1.4'
|
|
291
|
+
- - "<"
|
|
292
|
+
- !ruby/object:Gem::Version
|
|
293
|
+
version: '3'
|
|
294
294
|
- !ruby/object:Gem::Dependency
|
|
295
295
|
name: simplecov
|
|
296
296
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -384,8 +384,6 @@ files:
|
|
|
384
384
|
- app/controllers/concerns/bulkrax/download_behavior.rb
|
|
385
385
|
- app/controllers/concerns/bulkrax/guided_import_demo_scenarios.rb
|
|
386
386
|
- app/controllers/concerns/bulkrax/importer_file_handler.rb
|
|
387
|
-
- app/errors/bulkrax/unsafe_cloud_source_error.rb
|
|
388
|
-
- app/errors/bulkrax/unsafe_path_error.rb
|
|
389
387
|
- app/errors/bulkrax/unzip_error.rb
|
|
390
388
|
- app/factories/bulkrax/object_factory.rb
|
|
391
389
|
- app/factories/bulkrax/object_factory_interface.rb
|
|
@@ -422,7 +420,9 @@ files:
|
|
|
422
420
|
- app/models/bulkrax/csv_collection_entry.rb
|
|
423
421
|
- app/models/bulkrax/csv_entry.rb
|
|
424
422
|
- app/models/bulkrax/csv_file_set_entry.rb
|
|
423
|
+
- app/models/bulkrax/current.rb
|
|
425
424
|
- app/models/bulkrax/entry.rb
|
|
425
|
+
- app/models/bulkrax/export_scope.rb
|
|
426
426
|
- app/models/bulkrax/exporter.rb
|
|
427
427
|
- app/models/bulkrax/exporter_run.rb
|
|
428
428
|
- app/models/bulkrax/import_failed.rb
|
|
@@ -438,6 +438,7 @@ files:
|
|
|
438
438
|
- app/models/bulkrax/rdf_file_set_entry.rb
|
|
439
439
|
- app/models/bulkrax/status.rb
|
|
440
440
|
- app/models/bulkrax/xml_entry.rb
|
|
441
|
+
- app/models/concerns/bulkrax/ability_behavior.rb
|
|
441
442
|
- app/models/concerns/bulkrax/dynamic_record_lookup.rb
|
|
442
443
|
- app/models/concerns/bulkrax/errored_entries.rb
|
|
443
444
|
- app/models/concerns/bulkrax/export_behavior.rb
|
|
@@ -449,7 +450,6 @@ files:
|
|
|
449
450
|
- app/models/concerns/bulkrax/importer_exporter_behavior.rb
|
|
450
451
|
- app/models/concerns/bulkrax/status_info.rb
|
|
451
452
|
- app/parsers/bulkrax/application_parser.rb
|
|
452
|
-
- app/parsers/bulkrax/application_parser.rb.orig
|
|
453
453
|
- app/parsers/bulkrax/bagit_parser.rb
|
|
454
454
|
- app/parsers/bulkrax/csv_parser.rb
|
|
455
455
|
- app/parsers/bulkrax/oai_dc_parser.rb
|
|
@@ -460,7 +460,7 @@ files:
|
|
|
460
460
|
- app/parsers/concerns/bulkrax/csv_parser/csv_validation.rb
|
|
461
461
|
- app/parsers/concerns/bulkrax/csv_parser/csv_validation_helpers.rb
|
|
462
462
|
- app/parsers/concerns/bulkrax/csv_parser/csv_validation_hierarchy.rb
|
|
463
|
-
- app/
|
|
463
|
+
- app/search_builders/bulkrax/export_search_builder.rb
|
|
464
464
|
- app/services/bulkrax/csv_template/column_builder.rb
|
|
465
465
|
- app/services/bulkrax/csv_template/column_descriptor.rb
|
|
466
466
|
- app/services/bulkrax/csv_template/csv_builder.rb
|
|
@@ -476,7 +476,6 @@ files:
|
|
|
476
476
|
- app/services/bulkrax/csv_template/value_determiner.rb
|
|
477
477
|
- app/services/bulkrax/factory_class_finder.rb
|
|
478
478
|
- app/services/bulkrax/remove_relationships_for_importer.rb
|
|
479
|
-
- app/services/bulkrax/safe_path.rb
|
|
480
479
|
- app/services/bulkrax/split_pattern_coercion.rb
|
|
481
480
|
- app/services/bulkrax/stepper_response_formatter.rb
|
|
482
481
|
- app/services/bulkrax/validation_error_csv_builder.rb
|
|
@@ -588,7 +587,6 @@ files:
|
|
|
588
587
|
- lib/generators/bulkrax/templates/config/initializers/bulkrax.rb
|
|
589
588
|
- lib/tasks/bulkrax_tasks.rake
|
|
590
589
|
- lib/tasks/reset.rake
|
|
591
|
-
- lib/wings/custom_queries/find_by_source_identifier.rb
|
|
592
590
|
homepage: https://github.com/samvera-labs/bulkrax
|
|
593
591
|
licenses:
|
|
594
592
|
- Apache-2.0
|
|
@@ -607,7 +605,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
607
605
|
- !ruby/object:Gem::Version
|
|
608
606
|
version: '0'
|
|
609
607
|
requirements: []
|
|
610
|
-
rubygems_version:
|
|
608
|
+
rubygems_version: 4.0.22
|
|
611
609
|
specification_version: 4
|
|
612
610
|
summary: Import and export tool for Hyrax and Hyku
|
|
613
611
|
test_files: []
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Bulkrax
|
|
4
|
-
# Raised by {Bulkrax::CloudSourceValidator} when a cloud-file source
|
|
5
|
-
# (the `url` a user selected via browse-everything, or supplied directly
|
|
6
|
-
# in importer params) can't be safely downloaded: a scheme other than
|
|
7
|
-
# `file`/`http`/`https`, a `file:` source outside the configured
|
|
8
|
-
# filesystem-provider root, or an HTTP(S) source that resolves to a
|
|
9
|
-
# private, loopback, or link-local/metadata address.
|
|
10
|
-
class UnsafeCloudSourceError < StandardError; end
|
|
11
|
-
end
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Bulkrax
|
|
4
|
-
# Raised by {Bulkrax::SafePath} when a path would escape its configured
|
|
5
|
-
# root, whether that root is a ZIP extraction directory, an importer's
|
|
6
|
-
# trusted workspace, or a configured filesystem-provider home.
|
|
7
|
-
class UnsafePathError < StandardError; end
|
|
8
|
-
end
|