dor-services 4.22.3 → 4.22.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/bin/dor-indexer +19 -20
- data/bin/dor-indexerd +2 -3
- data/config/certs/robots-dor-dev.crt +29 -0
- data/config/certs/robots-dor-dev.key +27 -0
- data/config/dev_console_env.rb +77 -0
- data/lib/dor-services.rb +3 -3
- data/lib/dor/config.rb +15 -15
- data/lib/dor/datastreams/administrative_metadata_ds.rb +5 -5
- data/lib/dor/datastreams/content_metadata_ds.rb +181 -225
- data/lib/dor/datastreams/datastream_spec_solrizer.rb +1 -1
- data/lib/dor/datastreams/default_object_rights_ds.rb +8 -10
- data/lib/dor/datastreams/desc_metadata_ds.rb +35 -34
- data/lib/dor/datastreams/embargo_metadata_ds.rb +7 -7
- data/lib/dor/datastreams/events_ds.rb +11 -11
- data/lib/dor/datastreams/geo_metadata_ds.rb +86 -86
- data/lib/dor/datastreams/identity_metadata_ds.rb +19 -19
- data/lib/dor/datastreams/role_metadata_ds.rb +3 -3
- data/lib/dor/datastreams/simple_dublin_core_ds.rb +13 -13
- data/lib/dor/datastreams/version_metadata_ds.rb +5 -5
- data/lib/dor/datastreams/workflow_definition_ds.rb +21 -21
- data/lib/dor/migrations/identifiable/assert_adminPolicy.rb +1 -1
- data/lib/dor/migrations/identifiable/fix_model_assertions.rb +1 -1
- data/lib/dor/migrations/identifiable/record_remediation.rb +2 -2
- data/lib/dor/migrations/identifiable/uriify_augmented_contentlocation_refs.rb +1 -1
- data/lib/dor/migrations/identifiable/uriify_contentlocation_refs.rb +1 -1
- data/lib/dor/migrations/processable/unify_workflows.rb +4 -4
- data/lib/dor/migrations/versionable/add_missing_version_md.rb +1 -1
- data/lib/dor/models/admin_policy_object.rb +1 -1
- data/lib/dor/models/assembleable.rb +5 -5
- data/lib/dor/models/contentable.rb +27 -27
- data/lib/dor/models/describable.rb +168 -179
- data/lib/dor/models/discoverable.rb +13 -13
- data/lib/dor/models/editable.rb +55 -55
- data/lib/dor/models/embargoable.rb +26 -26
- data/lib/dor/models/eventable.rb +3 -3
- data/lib/dor/models/geoable.rb +8 -8
- data/lib/dor/models/governable.rb +14 -14
- data/lib/dor/models/identifiable.rb +117 -143
- data/lib/dor/models/item.rb +2 -2
- data/lib/dor/models/itemizable.rb +9 -9
- data/lib/dor/models/presentable.rb +8 -8
- data/lib/dor/models/preservable.rb +4 -4
- data/lib/dor/models/processable.rb +22 -23
- data/lib/dor/models/releaseable.rb +26 -26
- data/lib/dor/models/shelvable.rb +14 -14
- data/lib/dor/models/upgradable.rb +13 -13
- data/lib/dor/models/versionable.rb +2 -2
- data/lib/dor/models/workflow_object.rb +4 -4
- data/lib/dor/services/cleanup_reset_service.rb +27 -27
- data/lib/dor/services/cleanup_service.rb +4 -7
- data/lib/dor/services/digital_stacks_service.rb +10 -10
- data/lib/dor/services/merge_service.rb +1 -1
- data/lib/dor/services/metadata_handlers/mdtoolkit_handler.rb +2 -2
- data/lib/dor/services/metadata_service.rb +20 -20
- data/lib/dor/services/registration_service.rb +27 -27
- data/lib/dor/services/reset_workspace_service.rb +15 -15
- data/lib/dor/services/sdr_ingest_service.rb +6 -6
- data/lib/dor/services/search_service.rb +2 -2
- data/lib/dor/services/suri_service.rb +5 -5
- data/lib/dor/services/technical_metadata_service.rb +2 -3
- data/lib/dor/utils/ng_tidy.rb +9 -9
- data/lib/dor/utils/predicate_patch.rb +1 -1
- data/lib/dor/utils/solr_doc_helper.rb +2 -2
- data/lib/dor/version.rb +1 -1
- data/lib/dor/workflow/document.rb +19 -19
- data/lib/dor/workflow/graph.rb +36 -36
- data/lib/dor/workflow/process.rb +12 -12
- data/lib/tasks/dor.rake +1 -1
- data/lib/tasks/rdoc.rake +3 -3
- metadata +6 -3
@@ -17,11 +17,11 @@ module Dor
|
|
17
17
|
ds.label = 'Provenance Metadata'
|
18
18
|
end
|
19
19
|
ds.ng_xml = workflow_provenance
|
20
|
-
|
20
|
+
ds.content=ds.ng_xml.to_s
|
21
21
|
ds.save
|
22
22
|
end
|
23
23
|
|
24
|
-
def build_technicalMetadata_datastream(ds=nil)
|
24
|
+
def build_technicalMetadata_datastream(ds = nil)
|
25
25
|
TechnicalMetadataService.add_update_technical_metadata(self)
|
26
26
|
end
|
27
27
|
|
@@ -33,9 +33,9 @@ module Dor
|
|
33
33
|
# @return [Nokogiri::Document]
|
34
34
|
def create_workflow_provenance(workflow_id, event_text)
|
35
35
|
builder = Nokogiri::XML::Builder.new do |xml|
|
36
|
-
xml.provenanceMetadata(:objectId =>
|
36
|
+
xml.provenanceMetadata(:objectId => pid) {
|
37
37
|
xml.agent(:name => 'DOR') {
|
38
|
-
xml.what(:object =>
|
38
|
+
xml.what(:object => pid) {
|
39
39
|
xml.event(:who => "DOR-#{workflow_id}", :when => Time.new.iso8601) {
|
40
40
|
xml.text(event_text)
|
41
41
|
}
|
@@ -42,11 +42,11 @@ module Dor
|
|
42
42
|
# This is a work-around for some strange logic in ActiveFedora that
|
43
43
|
# don't allow self.workflows.new? to work if we load the object using
|
44
44
|
# .load_instance_from_solr.
|
45
|
-
return if self.respond_to?
|
45
|
+
return if self.respond_to?(:inner_object) && inner_object.is_a?(ActiveFedora::SolrDigitalObject)
|
46
46
|
|
47
|
-
if
|
47
|
+
if workflows.new?
|
48
48
|
workflows.mimeType = 'application/xml'
|
49
|
-
workflows.dsLocation = File.join(Dor::Config.workflow.url,"dor/objects/#{
|
49
|
+
workflows.dsLocation = File.join(Dor::Config.workflow.url,"dor/objects/#{pid}/workflows")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -54,7 +54,7 @@ module Dor
|
|
54
54
|
if datastream.new?
|
55
55
|
true
|
56
56
|
elsif datastream.class.respond_to?(:xml_template)
|
57
|
-
datastream.content.to_s.empty?
|
57
|
+
datastream.content.to_s.empty? || EquivalentXml.equivalent?(datastream.content, datastream.class.xml_template)
|
58
58
|
else
|
59
59
|
datastream.content.to_s.empty?
|
60
60
|
end
|
@@ -65,7 +65,7 @@ module Dor
|
|
65
65
|
# Returns the path to it or nil.
|
66
66
|
def find_metadata_file(datastream)
|
67
67
|
druid = DruidTools::Druid.new(pid, Dor::Config.stacks.local_workspace_root)
|
68
|
-
|
68
|
+
druid.find_metadata("#{datastream}.xml")
|
69
69
|
end
|
70
70
|
|
71
71
|
# Takes the name of a datastream, as a string (fooMetadata).
|
@@ -84,10 +84,10 @@ module Dor
|
|
84
84
|
ds.content = content
|
85
85
|
ds.ng_xml = Nokogiri::XML(content) if ds.respond_to?(:ng_xml)
|
86
86
|
ds.save unless ds.digital_object.new?
|
87
|
-
elsif force
|
87
|
+
elsif force || empty_datastream?(ds)
|
88
88
|
meth = "build_#{datastream}_datastream".to_sym
|
89
89
|
if respond_to?(meth)
|
90
|
-
content =
|
90
|
+
content = send(meth, ds)
|
91
91
|
ds.save unless ds.digital_object.new?
|
92
92
|
end
|
93
93
|
end
|
@@ -95,7 +95,7 @@ module Dor
|
|
95
95
|
if is_required && empty_datastream?(ds)
|
96
96
|
raise "Required datastream #{datastream} could not be populated!"
|
97
97
|
end
|
98
|
-
|
98
|
+
ds
|
99
99
|
end
|
100
100
|
|
101
101
|
def cleanup()
|
@@ -103,13 +103,13 @@ module Dor
|
|
103
103
|
end
|
104
104
|
|
105
105
|
def milestones
|
106
|
-
Dor::WorkflowService.get_milestones('dor',
|
106
|
+
Dor::WorkflowService.get_milestones('dor',pid)
|
107
107
|
end
|
108
108
|
|
109
109
|
def status_info()
|
110
110
|
current_version = '1'
|
111
111
|
begin
|
112
|
-
current_version =
|
112
|
+
current_version = versionMetadata.current_version_id
|
113
113
|
rescue
|
114
114
|
end
|
115
115
|
|
@@ -117,8 +117,8 @@ module Dor
|
|
117
117
|
#only get steps that are part of accessioning and part of the current version. That can mean they were archived with the current version
|
118
118
|
#number, or they might be active (no version number).
|
119
119
|
milestones.each do |m|
|
120
|
-
if STEPS.keys.include?(m[:milestone])
|
121
|
-
current_milestones << m unless m[:milestone] == 'registered'
|
120
|
+
if STEPS.keys.include?(m[:milestone]) && (m[:version].nil? || m[:version] == current_version)
|
121
|
+
current_milestones << m unless m[:milestone] == 'registered' && current_version.to_i > 1
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
@@ -136,25 +136,25 @@ module Dor
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
-
|
139
|
+
{:current_version => current_version, :status_code => status_code, :status_time => status_time}
|
140
140
|
end
|
141
141
|
|
142
|
-
def status(include_time=false)
|
142
|
+
def status(include_time = false)
|
143
143
|
status_info_hash = status_info
|
144
144
|
current_version, status_code, status_time = status_info_hash[:current_version], status_info_hash[:status_code], status_info_hash[:status_time]
|
145
145
|
|
146
146
|
#use the translation table to get the appropriate verbage for the latest step
|
147
147
|
result = "v#{current_version} #{STATUS_CODE_DISP_TXT[status_code]}"
|
148
148
|
result += " #{format_date(status_time)}" if include_time
|
149
|
-
|
149
|
+
result
|
150
150
|
end
|
151
151
|
|
152
|
-
def to_solr(solr_doc=Hash.new, *args)
|
152
|
+
def to_solr(solr_doc = Hash.new, *args)
|
153
153
|
super(solr_doc, *args)
|
154
154
|
sortable_milestones = {}
|
155
155
|
current_version='1'
|
156
156
|
begin
|
157
|
-
current_version =
|
157
|
+
current_version = versionMetadata.current_version_id
|
158
158
|
rescue
|
159
159
|
end
|
160
160
|
current_version_num=current_version.to_i
|
@@ -162,12 +162,12 @@ module Dor
|
|
162
162
|
if self.respond_to?('versionMetadata')
|
163
163
|
#add an entry with version id, tag and description for each version
|
164
164
|
while current_version_num > 0
|
165
|
-
add_solr_value(solr_doc, 'versions', current_version_num.to_s + ';' +
|
165
|
+
add_solr_value(solr_doc, 'versions', current_version_num.to_s + ';' + versionMetadata.tag_for_version(current_version_num.to_s) + ';' + versionMetadata.description_for_version(current_version_num.to_s), :string, [:displayable])
|
166
166
|
current_version_num -= 1
|
167
167
|
end
|
168
168
|
end
|
169
169
|
|
170
|
-
|
170
|
+
milestones.each do |milestone|
|
171
171
|
timestamp = milestone[:at].utc.xmlschema
|
172
172
|
sortable_milestones[milestone[:milestone]] ||= []
|
173
173
|
sortable_milestones[milestone[:milestone]] << timestamp
|
@@ -201,7 +201,7 @@ module Dor
|
|
201
201
|
add_solr_value(solr_doc, "version_opened", DateTime.parse(opened_date).beginning_of_day.utc.xmlschema.split('T').first, :string, [ :searchable, :facetable])
|
202
202
|
end
|
203
203
|
add_solr_value(solr_doc, "current_version", current_version.to_s, :string, [ :displayable , :facetable])
|
204
|
-
add_solr_value(solr_doc, "last_modified_day",
|
204
|
+
add_solr_value(solr_doc, "last_modified_day", modified_date.to_s.split('T').first, :string, [ :facetable ])
|
205
205
|
add_solr_value(solr_doc, "rights", rights, :string, [:facetable]) if self.respond_to? :rights
|
206
206
|
solr_doc
|
207
207
|
end
|
@@ -212,12 +212,12 @@ module Dor
|
|
212
212
|
# @param [String] name of the workflow to be initialized
|
213
213
|
# @param [Boolean] create_ds create a 'workflows' datastream in Fedora for the object
|
214
214
|
# @param [Integer] priority the workflow's priority level
|
215
|
-
def initialize_workflow(name, create_ds=true, priority=0)
|
215
|
+
def initialize_workflow(name, create_ds = true, priority = 0)
|
216
216
|
priority = workflows.current_priority if priority == 0
|
217
217
|
opts = { :create_ds => create_ds }
|
218
218
|
opts[:priority] = priority if(priority > 0)
|
219
219
|
opts[:lane_id] = default_workflow_lane
|
220
|
-
Dor::WorkflowService.create_workflow(Dor::WorkflowObject.initial_repo(name),
|
220
|
+
Dor::WorkflowService.create_workflow(Dor::WorkflowObject.initial_repo(name), pid, name, Dor::WorkflowObject.initial_workflow(name), opts)
|
221
221
|
end
|
222
222
|
|
223
223
|
|
@@ -237,4 +237,3 @@ module Dor
|
|
237
237
|
|
238
238
|
|
239
239
|
end
|
240
|
-
|
@@ -18,7 +18,7 @@ module Dor
|
|
18
18
|
|
19
19
|
# Add in each tag
|
20
20
|
release_tags.each do |r_tag|
|
21
|
-
|
21
|
+
add_release_node(r_tag[:release],r_tag)
|
22
22
|
end
|
23
23
|
|
24
24
|
# Save item to dor so the robots work with the latest data
|
@@ -54,7 +54,7 @@ module Dor
|
|
54
54
|
# Get the most recent self tag for all targets and save their result since most recent self always trumps any other non self tags
|
55
55
|
latest_self_tags = get_newest_release_tag(self_release_tags)
|
56
56
|
latest_self_tags.keys.each do |target|
|
57
|
-
released_hash[target] =
|
57
|
+
released_hash[target] = clean_release_tag_for_purl(latest_self_tags[target])
|
58
58
|
end
|
59
59
|
|
60
60
|
# With Self Tags Resolved We Now need to deal with tags on all sets this object is part of
|
@@ -83,7 +83,7 @@ module Dor
|
|
83
83
|
#
|
84
84
|
#@return [Hash] a hash of self tags for each to value
|
85
85
|
def get_self_release_tags(tags)
|
86
|
-
|
86
|
+
get_tags_for_what_value(tags, 'self')
|
87
87
|
end
|
88
88
|
|
89
89
|
#Take an item and get all of its release tags and all tags on collections it is a member of it
|
@@ -95,7 +95,7 @@ module Dor
|
|
95
95
|
collections.each do |collection|
|
96
96
|
return_tags = combine_two_release_tag_hashes(return_tags, Dor::Item.find(collection.id).get_release_tags_for_item_and_all_governing_sets) # recurvise so parents of parents are found
|
97
97
|
end
|
98
|
-
|
98
|
+
return_tags
|
99
99
|
end
|
100
100
|
|
101
101
|
#Take two hashes of tags and combine them, will not overwrite but will enforce uniqueness of the tags
|
@@ -106,10 +106,10 @@ module Dor
|
|
106
106
|
#@return [Hash] the combined hash with uniquiness enforced
|
107
107
|
def combine_two_release_tag_hashes(hash_one, hash_two)
|
108
108
|
hash_two.keys.each do |key|
|
109
|
-
hash_one[key] = hash_two[key] if hash_one[key]
|
110
|
-
hash_one[key] = (hash_one[key] + hash_two[key]).uniq
|
109
|
+
hash_one[key] = hash_two[key] if hash_one[key].nil?
|
110
|
+
hash_one[key] = (hash_one[key] + hash_two[key]).uniq unless hash_one[key].nil?
|
111
111
|
end
|
112
|
-
|
112
|
+
hash_one
|
113
113
|
end
|
114
114
|
|
115
115
|
#Take a hash of tags and return all tags with the matching what target
|
@@ -124,7 +124,7 @@ module Dor
|
|
124
124
|
self_tags = tags[key].select {|tag| tag['what'] == what_target.downcase}
|
125
125
|
return_hash[key] = self_tags if self_tags.size > 0
|
126
126
|
end
|
127
|
-
|
127
|
+
return_hash
|
128
128
|
end
|
129
129
|
|
130
130
|
#Take a hash of tags as obtained via Dor::Item.release_tags and returns the newest tag for each namespace
|
@@ -153,7 +153,7 @@ module Dor
|
|
153
153
|
array_of_tags.each do |tag|
|
154
154
|
latest_tag_in_array = tag if tag['when'] > latest_tag_in_array['when']
|
155
155
|
end
|
156
|
-
|
156
|
+
latest_tag_in_array
|
157
157
|
end
|
158
158
|
|
159
159
|
# Takes a tag and returns true or false if it applies to the specific item
|
@@ -189,17 +189,17 @@ module Dor
|
|
189
189
|
#
|
190
190
|
#@return [Nokogiri::XML::NodeSet] of all release tags and their attributes
|
191
191
|
def release_tags
|
192
|
-
release_tags =
|
192
|
+
release_tags = identityMetadata.ng_xml.xpath('//release')
|
193
193
|
return_hash = {}
|
194
194
|
release_tags.each do |release_tag|
|
195
|
-
hashed_node =
|
196
|
-
if return_hash[hashed_node[:to]]
|
195
|
+
hashed_node = release_tag_node_to_hash(release_tag)
|
196
|
+
if !return_hash[hashed_node[:to]].nil?
|
197
197
|
return_hash[hashed_node[:to]] << hashed_node[:attrs]
|
198
198
|
else
|
199
199
|
return_hash[hashed_node[:to]] = [hashed_node[:attrs]]
|
200
200
|
end
|
201
201
|
end
|
202
|
-
|
202
|
+
return_hash
|
203
203
|
end
|
204
204
|
|
205
205
|
#method to convert one release element into an array
|
@@ -239,8 +239,8 @@ module Dor
|
|
239
239
|
#
|
240
240
|
#@example
|
241
241
|
# item.add_tag(true,:release,{:tag=>'Fitch : Batch2',:what=>'self',:to=>'Searchworks',:who=>'petucket', :displayType='filmstrip'})
|
242
|
-
def add_release_node(release, attrs={})
|
243
|
-
identity_metadata_ds =
|
242
|
+
def add_release_node(release, attrs = {})
|
243
|
+
identity_metadata_ds = identityMetadata
|
244
244
|
attrs[:when] = Time.now.utc.iso8601 if attrs[:when].nil? #add the timestamp
|
245
245
|
attrs[:displayType] = 'file' if attrs[:displayType].nil? #default to file is no display type is passed
|
246
246
|
valid_release_attributes(release, attrs)
|
@@ -258,8 +258,8 @@ module Dor
|
|
258
258
|
#@return [Boolean] Returns true if no errors found
|
259
259
|
#
|
260
260
|
#@params attrs [hash] A hash of attributes for the tag, must contain :when, a ISO 8601 timestamp and :who to identify who or what added the tag, :to,
|
261
|
-
def valid_release_attributes(tag, attrs={})
|
262
|
-
raise ArgumentError, ":when is not iso8601" if attrs[:when].match('\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z')
|
261
|
+
def valid_release_attributes(tag, attrs = {})
|
262
|
+
raise ArgumentError, ":when is not iso8601" if attrs[:when].match('\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z').nil?
|
263
263
|
[:who, :to, :what].each do |check_attr|
|
264
264
|
raise ArgumentError, "#{check_attr} not supplied as a String" if attrs[check_attr].class != String
|
265
265
|
end
|
@@ -280,17 +280,17 @@ module Dor
|
|
280
280
|
#
|
281
281
|
#@return [Nokogiri::XML::NodeSet] of all release tags and their attributes
|
282
282
|
def release_nodes
|
283
|
-
release_tags =
|
283
|
+
release_tags = identityMetadata.ng_xml.xpath('//release')
|
284
284
|
return_hash = {}
|
285
285
|
release_tags.each do |release_tag|
|
286
|
-
hashed_node =
|
287
|
-
if return_hash[hashed_node[:to]]
|
286
|
+
hashed_node = release_tag_node_to_hash(release_tag)
|
287
|
+
if !return_hash[hashed_node[:to]].nil?
|
288
288
|
return_hash[hashed_node[:to]] << hashed_node[:attrs]
|
289
289
|
else
|
290
290
|
return_hash[hashed_node[:to]] = [hashed_node[:attrs]]
|
291
291
|
end
|
292
292
|
end
|
293
|
-
|
293
|
+
return_hash
|
294
294
|
end
|
295
295
|
|
296
296
|
#Get a list of all release nodes found in a purl document
|
@@ -323,8 +323,8 @@ module Dor
|
|
323
323
|
#@return [String] the druid sans the druid: or if there was no druid: prefix, the entire string you passed
|
324
324
|
def remove_druid_prefix
|
325
325
|
druid_prefix = "druid:"
|
326
|
-
return
|
327
|
-
|
326
|
+
return id.split(druid_prefix)[1] if id.split(druid_prefix).size > 1
|
327
|
+
druid
|
328
328
|
end
|
329
329
|
|
330
330
|
# Take the and create the entire purl url that will usable for the open method in open-uri, returns https
|
@@ -348,8 +348,8 @@ module Dor
|
|
348
348
|
#
|
349
349
|
#@return [Array] An array containing all the release tags
|
350
350
|
def get_release_tags_from_purl
|
351
|
-
xml =
|
352
|
-
|
351
|
+
xml = get_xml_from_purl
|
352
|
+
get_release_tags_from_purl_xml(xml)
|
353
353
|
end
|
354
354
|
|
355
355
|
# This function calls purl and gets a list of all release tags currently in purl. It then compares to the list you have generated.
|
@@ -362,7 +362,7 @@ module Dor
|
|
362
362
|
missing_tags.each do |missing_tag|
|
363
363
|
new_tags[missing_tag.capitalize] = {"release"=>false}
|
364
364
|
end
|
365
|
-
|
365
|
+
new_tags
|
366
366
|
end
|
367
367
|
|
368
368
|
def to_solr(solr_doc = {}, *args)
|
data/lib/dor/models/shelvable.rb
CHANGED
@@ -25,7 +25,7 @@ module Dor
|
|
25
25
|
# retrieve the differences between the current contentMetadata and the previously ingested version
|
26
26
|
# (filtering to select only the files that should be shelved to stacks)
|
27
27
|
def get_shelve_diff
|
28
|
-
inventory_diff_xml =
|
28
|
+
inventory_diff_xml = get_content_diff(:shelve)
|
29
29
|
inventory_diff = Moab::FileInventoryDifference.parse(inventory_diff_xml)
|
30
30
|
shelve_diff = inventory_diff.group_difference("content")
|
31
31
|
shelve_diff
|
@@ -35,30 +35,30 @@ module Dor
|
|
35
35
|
# @param [Moab::FileGroupDifference] content_diff The differences between the current contentMetadata and the previously ingested version
|
36
36
|
# @param [DruidTools::Druid] workspace_druid the location of the object's files in the workspace area
|
37
37
|
# @return [Pathname] The location of the object's content files in the workspace area
|
38
|
-
def workspace_content_dir
|
38
|
+
def workspace_content_dir(content_diff, workspace_druid)
|
39
39
|
deltas = content_diff.file_deltas
|
40
40
|
filelist = deltas[:modified] + deltas[:added] + deltas[:copyadded].collect{|old,new| new}
|
41
41
|
return nil if filelist.empty?
|
42
42
|
content_pathname = Pathname(workspace_druid.find_filelist_parent('content', filelist))
|
43
43
|
content_pathname
|
44
44
|
end
|
45
|
-
|
46
|
-
|
47
|
-
# get the stack location based on the contentMetadata stacks attribute
|
45
|
+
|
46
|
+
|
47
|
+
# get the stack location based on the contentMetadata stacks attribute
|
48
48
|
# or using the default value from the config file if it doesn't exist
|
49
49
|
def get_stacks_location
|
50
|
-
|
51
|
-
contentMetadataDS =
|
52
|
-
unless contentMetadataDS.nil?
|
53
|
-
stacks_location = contentMetadataDS.stacks[0]
|
50
|
+
|
51
|
+
contentMetadataDS = datastreams['contentMetadata']
|
52
|
+
unless contentMetadataDS.nil? || contentMetadataDS.stacks.length == 0
|
53
|
+
stacks_location = contentMetadataDS.stacks[0]
|
54
54
|
if stacks_location.start_with?"/" #Absolute stacks path
|
55
55
|
return stacks_location
|
56
|
-
else
|
57
|
-
raise "stacks attribute for item: "+
|
56
|
+
else
|
57
|
+
raise "stacks attribute for item: "+id+ " contentMetadata should start with /. The current value is "+stacks_location
|
58
58
|
end
|
59
|
-
end
|
60
|
-
|
61
|
-
|
59
|
+
end
|
60
|
+
Config.stacks.local_stacks_root #Default stacks
|
61
|
+
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
module Dor
|
2
2
|
module Upgradable
|
3
3
|
|
4
|
-
# The Upgradable mixin is responsible for making sure all DOR objects,
|
5
|
-
# concerns, and datastreams know how to upgrade themselves to the latest
|
4
|
+
# The Upgradable mixin is responsible for making sure all DOR objects,
|
5
|
+
# concerns, and datastreams know how to upgrade themselves to the latest
|
6
6
|
# Chimera/DOR content standards.
|
7
7
|
#
|
8
8
|
# To add a new upgrade:
|
9
9
|
# 1) include Dor::Upgradable within whatever model, datastream, or mixin
|
10
10
|
# you want to make upgradable.
|
11
11
|
# 2) Add a block to the model, datastream, or mixin as follows:
|
12
|
-
#
|
13
|
-
# on_upgrade(v) do |obj|
|
12
|
+
#
|
13
|
+
# on_upgrade(v) do |obj|
|
14
14
|
# # Do whatever needs to be done to obj
|
15
15
|
# end
|
16
16
|
#
|
@@ -20,7 +20,7 @@ module Dor
|
|
20
20
|
# The block can either be defined on the model itself, or in a file
|
21
21
|
# in the dor/migrations/[model] directory. See Dor::Identifiable and
|
22
22
|
# dor/migrations/identifiable/* for an example.
|
23
|
-
|
23
|
+
|
24
24
|
Callback = Struct.new :module, :version, :description, :block
|
25
25
|
|
26
26
|
mattr_accessor :__upgrade_callbacks
|
@@ -28,12 +28,12 @@ module Dor
|
|
28
28
|
def self.add_upgrade_callback c, v, d, &b
|
29
29
|
@@__upgrade_callbacks << Callback.new(c, Gem::Version.new(v), d, b)
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
def self.run_upgrade_callbacks(obj, event_handler)
|
33
33
|
relevant = @@__upgrade_callbacks.select { |c| obj.is_a?(c.module) }.sort_by(&:version)
|
34
|
-
results = relevant.collect do |c|
|
34
|
+
results = relevant.collect do |c|
|
35
35
|
result = c.block.call(obj)
|
36
|
-
if result
|
36
|
+
if result && event_handler.respond_to?(:add_event)
|
37
37
|
event_handler.add_event 'remediation', "#{c.module.name} #{c.version}", c.description
|
38
38
|
end
|
39
39
|
if result
|
@@ -43,29 +43,29 @@ module Dor
|
|
43
43
|
end
|
44
44
|
results.any?
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
def self.included(base)
|
48
48
|
base.instance_eval do
|
49
49
|
def self.on_upgrade version, desc, &block
|
50
50
|
Dor::Upgradable.add_upgrade_callback self, version, desc, &block
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
Dir[File.join(Dor.root,'dor','migrations',base.name.split(/::/).last.underscore,'*.rb')].each do |migration|
|
54
54
|
require migration
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
def upgrade!
|
60
60
|
results = [Dor::Upgradable.run_upgrade_callbacks(self, self)]
|
61
61
|
if self.respond_to?(:datastreams)
|
62
|
-
|
62
|
+
datastreams.each_pair do |dsid, ds|
|
63
63
|
results << Dor::Upgradable.run_upgrade_callbacks(ds, self) unless ds.new?
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
67
|
if results.any?
|
68
|
-
|
68
|
+
save
|
69
69
|
else
|
70
70
|
false
|
71
71
|
end
|