dor-services 6.0.5 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dor-services.rb +27 -12
  3. data/lib/dor/config.rb +45 -42
  4. data/lib/dor/datastreams/administrative_metadata_ds.rb +137 -44
  5. data/lib/dor/datastreams/content_metadata_ds.rb +42 -42
  6. data/lib/dor/datastreams/datastream_spec_solrizer.rb +1 -1
  7. data/lib/dor/datastreams/default_object_rights_ds.rb +185 -44
  8. data/lib/dor/datastreams/desc_metadata_ds.rb +36 -28
  9. data/lib/dor/datastreams/embargo_metadata_ds.rb +12 -14
  10. data/lib/dor/datastreams/events_ds.rb +10 -10
  11. data/lib/dor/datastreams/geo_metadata_ds.rb +4 -5
  12. data/lib/dor/datastreams/identity_metadata_ds.rb +14 -14
  13. data/lib/dor/datastreams/rights_metadata_ds.rb +23 -23
  14. data/lib/dor/datastreams/role_metadata_ds.rb +61 -15
  15. data/lib/dor/datastreams/simple_dublin_core_ds.rb +8 -8
  16. data/lib/dor/datastreams/version_metadata_ds.rb +10 -12
  17. data/lib/dor/datastreams/workflow_definition_ds.rb +6 -6
  18. data/lib/dor/datastreams/workflow_ds.rb +13 -13
  19. data/lib/dor/exceptions.rb +2 -2
  20. data/lib/dor/indexers/data_indexer.rb +1 -7
  21. data/lib/dor/indexers/describable_indexer.rb +1 -1
  22. data/lib/dor/indexers/identifiable_indexer.rb +0 -2
  23. data/lib/dor/indexers/processable_indexer.rb +55 -28
  24. data/lib/dor/indexers/releasable_indexer.rb +2 -2
  25. data/lib/dor/models/admin_policy_object.rb +4 -4
  26. data/lib/dor/models/concerns/assembleable.rb +4 -0
  27. data/lib/dor/models/concerns/contentable.rb +27 -69
  28. data/lib/dor/models/concerns/describable.rb +14 -29
  29. data/lib/dor/models/concerns/editable.rb +20 -334
  30. data/lib/dor/models/concerns/embargoable.rb +7 -11
  31. data/lib/dor/models/concerns/eventable.rb +5 -1
  32. data/lib/dor/models/concerns/geoable.rb +4 -4
  33. data/lib/dor/models/concerns/governable.rb +18 -87
  34. data/lib/dor/models/concerns/identifiable.rb +15 -75
  35. data/lib/dor/models/concerns/itemizable.rb +9 -11
  36. data/lib/dor/models/concerns/preservable.rb +4 -0
  37. data/lib/dor/models/concerns/processable.rb +30 -129
  38. data/lib/dor/models/concerns/publishable.rb +6 -55
  39. data/lib/dor/models/concerns/releaseable.rb +14 -227
  40. data/lib/dor/models/concerns/rightsable.rb +3 -3
  41. data/lib/dor/models/concerns/shelvable.rb +4 -49
  42. data/lib/dor/models/concerns/versionable.rb +21 -44
  43. data/lib/dor/models/set.rb +1 -1
  44. data/lib/dor/models/workflow_object.rb +2 -2
  45. data/lib/dor/services/ability.rb +77 -0
  46. data/lib/dor/services/cleanup_reset_service.rb +1 -3
  47. data/lib/dor/services/create_workflow_service.rb +51 -0
  48. data/lib/dor/services/creative_commons_license_service.rb +31 -0
  49. data/lib/dor/services/datastream_builder.rb +90 -0
  50. data/lib/dor/services/digital_stacks_service.rb +3 -21
  51. data/lib/dor/services/dublin_core_service.rb +40 -0
  52. data/lib/dor/services/file_metadata_merge_service.rb +67 -0
  53. data/lib/dor/services/indexing_service.rb +8 -4
  54. data/lib/dor/services/merge_service.rb +5 -5
  55. data/lib/dor/services/metadata_handlers/catalog_handler.rb +1 -1
  56. data/lib/dor/services/metadata_service.rb +6 -8
  57. data/lib/dor/{models/concerns → services}/mods2dc.xslt +0 -0
  58. data/lib/dor/services/ontology.rb +35 -0
  59. data/lib/dor/services/open_data_license_service.rb +20 -0
  60. data/lib/dor/services/public_desc_metadata_service.rb +21 -14
  61. data/lib/dor/services/public_xml_service.rb +6 -6
  62. data/lib/dor/services/publish_metadata_service.rb +100 -0
  63. data/lib/dor/services/registration_service.rb +43 -46
  64. data/lib/dor/services/release_tag_service.rb +251 -0
  65. data/lib/dor/services/reset_workspace_service.rb +1 -3
  66. data/lib/dor/services/sdr_ingest_service.rb +5 -7
  67. data/lib/dor/services/search_service.rb +10 -10
  68. data/lib/dor/services/secondary_file_name_service.rb +10 -0
  69. data/lib/dor/services/shelving_service.rb +67 -0
  70. data/lib/dor/services/status_service.rb +121 -0
  71. data/lib/dor/services/suri_service.rb +3 -5
  72. data/lib/dor/services/tag_service.rb +100 -0
  73. data/lib/dor/services/technical_metadata_service.rb +5 -4
  74. data/lib/dor/services/version_service.rb +84 -0
  75. data/lib/dor/utils/ng_tidy.rb +1 -1
  76. data/lib/dor/utils/sdr_client.rb +25 -9
  77. data/lib/dor/version.rb +1 -1
  78. data/lib/dor/workflow/document.rb +13 -13
  79. data/lib/dor/workflow/process.rb +71 -26
  80. data/lib/tasks/rdoc.rake +1 -1
  81. metadata +77 -51
  82. data/config/certs/robots-dor-dev.crt +0 -29
  83. data/config/certs/robots-dor-dev.key +0 -27
  84. data/config/dev_console_env.rb +0 -80
@@ -18,13 +18,7 @@ module Dor
18
18
  end
19
19
  end
20
20
 
21
- # rubocop:disable Naming/PredicateName
22
- def has_model
23
- resource.class.inspect
24
- end
25
- # rubocop:enable Naming/PredicateName
26
-
27
21
  delegate :create_date, :modified_date, :state, :pid, :inner_object,
28
- :datastreams, :relationships, to: :resource
22
+ :datastreams, :relationships, :has_model, to: :resource
29
23
  end
30
24
  end
@@ -28,7 +28,7 @@ module Dor
28
28
  topic_facet: %w(sw_topic_ssim sw_topic_tesim),
29
29
  era_facet: %w(sw_subject_temporal_ssim sw_subject_temporal_tesim),
30
30
  geographic_facet: %w(sw_subject_geographic_ssim sw_subject_geographic_tesim),
31
- [:term_values, :typeOfResource] => %w(mods_typeOfResource_ssim mods_typeOfResource_tesim),
31
+ %i[term_values typeOfResource] => %w(mods_typeOfResource_ssim mods_typeOfResource_tesim),
32
32
  pub_year_sort_str: %w(sw_pub_date_sort_ssi),
33
33
  pub_year_int: %w(sw_pub_date_sort_isi),
34
34
  pub_year_display_str: %w(sw_pub_date_facet_ssi)
@@ -17,8 +17,6 @@ module Dor
17
17
  # @return [Hash] the partial solr document for identifiable concerns
18
18
  def to_solr
19
19
  solr_doc = {}
20
- resource.assert_content_model
21
-
22
20
  solr_doc[Dor::INDEX_VERSION_FIELD] = Dor::VERSION
23
21
  solr_doc['indexed_at_dtsi'] = Time.now.utc.xmlschema
24
22
  resource.datastreams.values.each do |ds|
@@ -7,38 +7,62 @@ module Dor
7
7
  attr_reader :resource
8
8
  def initialize(resource:)
9
9
  @resource = resource
10
+ @status_service = StatusService.new(resource)
10
11
  end
11
12
 
12
13
  # @return [Hash] the partial solr document for processable concerns
13
14
  def to_solr
14
- solr_doc = {}
15
- sortable_milestones = {}
16
- current_version = '1'
17
- begin
18
- current_version = resource.versionMetadata.current_version_id
19
- rescue StandardError
15
+ {}.tap do |solr_doc|
16
+ add_versions(solr_doc)
17
+ add_milestones(solr_doc)
18
+ solr_doc['modified_latest_dttsi'] = resource.modified_date.to_datetime.utc.strftime('%FT%TZ')
19
+ add_solr_value(solr_doc, 'rights', resource.rights, :string, [:symbol]) if resource.respond_to? :rights
20
+ add_status(solr_doc)
20
21
  end
21
- current_version_num = current_version.to_i
22
+ end
22
23
 
23
- if resource.respond_to?('versionMetadata')
24
- # add an entry with version id, tag and description for each version
25
- while current_version_num > 0
26
- new_val = "#{current_version_num};#{resource.versionMetadata.tag_for_version(current_version_num.to_s)};#{resource.versionMetadata.description_for_version(current_version_num.to_s)}"
27
- add_solr_value(solr_doc, 'versions', new_val, :string, [:displayable])
28
- current_version_num -= 1
29
- end
30
- end
24
+ private
25
+
26
+ attr_reader :status_service
27
+
28
+ def current_version
29
+ @current_version ||= begin
30
+ resource.versionMetadata.current_version_id
31
+ rescue StandardError
32
+ '1'
33
+ end
34
+ end
35
+
36
+ def add_status(solr_doc)
37
+ solr_doc['status_ssi'] = status_service.status # status is singular (i.e. the current one)
38
+ status_info_hash = status_service.status_info
39
+ status_code = status_info_hash[:status_code]
40
+ add_solr_value(solr_doc, 'processing_status_text', simplified_status_code_disp_txt(status_code), :string, [:stored_sortable])
41
+ solr_doc['processing_status_code_isi'] = status_code
42
+ end
31
43
 
32
- resource.milestones.each do |milestone|
44
+ def add_milestones(solr_doc)
45
+ status_service.milestones.each do |milestone|
33
46
  timestamp = milestone[:at].utc.xmlschema
34
- sortable_milestones[milestone[:milestone]] ||= []
35
- sortable_milestones[milestone[:milestone]] << timestamp
36
47
  milestone[:version] ||= current_version
37
48
  solr_doc['lifecycle_ssim'] ||= []
38
49
  solr_doc['lifecycle_ssim'] << milestone[:milestone]
39
50
  add_solr_value(solr_doc, 'lifecycle', "#{milestone[:milestone]}:#{timestamp};#{milestone[:version]}", :symbol)
40
51
  end
41
52
 
53
+ add_sortable_milestones(solr_doc)
54
+ end
55
+
56
+ def sortable_milestones
57
+ sortable = {}
58
+ status_service.milestones.each do |milestone|
59
+ sortable[milestone[:milestone]] ||= []
60
+ sortable[milestone[:milestone]] << milestone[:at].utc.xmlschema
61
+ end
62
+ sortable
63
+ end
64
+
65
+ def add_sortable_milestones(solr_doc)
42
66
  sortable_milestones.each do |milestone, unordered_dates|
43
67
  dates = unordered_dates.sort
44
68
  # create the published_dttsi and published_day fields and the like
@@ -50,23 +74,26 @@ module Dor
50
74
  solr_doc["#{milestone}_earliest_dttsi"] = dates.first
51
75
  solr_doc["#{milestone}_latest_dttsi"] = dates.last
52
76
  end
53
- solr_doc['status_ssi'] = resource.status # status is singular (i.e. the current one)
54
- solr_doc['current_version_isi'] = current_version.to_i
55
- solr_doc['modified_latest_dttsi'] = resource.modified_date.to_datetime.utc.strftime('%FT%TZ')
56
- add_solr_value(solr_doc, 'rights', resource.rights, :string, [:symbol]) if resource.respond_to? :rights
77
+ end
57
78
 
58
- status_info_hash = resource.status_info
59
- status_code = status_info_hash[:status_code]
60
- add_solr_value(solr_doc, 'processing_status_text', simplified_status_code_disp_txt(status_code), :string, [:stored_sortable])
61
- solr_doc['processing_status_code_isi'] = status_code # no _isi in Solrizer's default descriptors
79
+ def add_versions(solr_doc)
80
+ current_version_num = current_version.to_i
81
+ solr_doc['current_version_isi'] = current_version_num
62
82
 
63
- solr_doc
83
+ return unless resource.respond_to?('versionMetadata')
84
+
85
+ # add an entry with version id, tag and description for each version
86
+ while current_version_num > 0
87
+ new_val = "#{current_version_num};#{resource.versionMetadata.tag_for_version(current_version_num.to_s)};#{resource.versionMetadata.description_for_version(current_version_num.to_s)}"
88
+ add_solr_value(solr_doc, 'versions', new_val, :string, [:displayable])
89
+ current_version_num -= 1
90
+ end
64
91
  end
65
92
 
66
93
  # @return [String] text translation of the status code, minus any trailing parenthetical explanation
67
94
  # e.g. 'In accessioning (described)' and 'In accessioning (described, published)' both return 'In accessioning'
68
95
  def simplified_status_code_disp_txt(status_code)
69
- Processable::STATUS_CODE_DISP_TXT[status_code].gsub(/\(.*\)$/, '').strip
96
+ StatusService::STATUS_CODE_DISP_TXT[status_code].gsub(/\(.*\)$/, '').strip
70
97
  end
71
98
  end
72
99
  end
@@ -15,9 +15,9 @@ module Dor
15
15
 
16
16
  # TODO: sort of worried about the performance impact in bulk reindex
17
17
  # situations, since released_for recurses all parent collections. jmartin 2015-07-14
18
- resource.released_for(true).each { |release_target, release_info|
18
+ resource.released_for(true).each do |release_target, release_info|
19
19
  add_solr_value(solr_doc, 'released_to', release_target, :symbol, []) if release_info['release']
20
- }
20
+ end
21
21
 
22
22
  # TODO: need to solrize whether item is released to purl? does released_for return that?
23
23
  # logic is: "True when there is a published lifecycle and Access Rights is anything but Dark"
@@ -4,11 +4,11 @@ module Dor
4
4
  class AdminPolicyObject < Dor::Abstract
5
5
  include Editable
6
6
 
7
- has_many :things, :property => :is_governed_by, :class_name => 'ActiveFedora::Base'
7
+ has_many :things, property: :is_governed_by, class_name: 'ActiveFedora::Base'
8
8
  has_object_type 'adminPolicy'
9
- has_metadata :name => 'administrativeMetadata', :type => Dor::AdministrativeMetadataDS, :label => 'Administrative Metadata'
10
- has_metadata :name => 'roleMetadata', :type => Dor::RoleMetadataDS, :label => 'Role Metadata'
11
- has_metadata :name => 'defaultObjectRights', :type => Dor::DefaultObjectRightsDS, :label => 'Default Object Rights'
9
+ has_metadata name: 'administrativeMetadata', type: Dor::AdministrativeMetadataDS, label: 'Administrative Metadata'
10
+ has_metadata name: 'roleMetadata', type: Dor::RoleMetadataDS, label: 'Role Metadata'
11
+ has_metadata name: 'defaultObjectRights', type: Dor::DefaultObjectRightsDS, label: 'Default Object Rights'
12
12
 
13
13
  self.resource_indexer = CompositeIndexer.new(
14
14
  DataIndexer,
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Dor
4
4
  module Assembleable
5
+ extend Deprecation
6
+ self.deprecation_horizon = 'dor-services version 7.0.0'
7
+
5
8
  def initialize_workspace(source = nil)
6
9
  druid = DruidTools::Druid.new(pid, Config.stacks.local_workspace_root)
7
10
  if source.nil?
@@ -10,5 +13,6 @@ module Dor
10
13
  druid.mkdir_with_final_link(source)
11
14
  end
12
15
  end
16
+ deprecation_deprecate initialize_workspace: 'This functionality has moved to dor_services_app'
13
17
  end
14
18
  end
@@ -3,6 +3,8 @@
3
3
  module Dor
4
4
  module Contentable
5
5
  extend ActiveSupport::Concern
6
+ extend Deprecation
7
+ self.deprecation_horizon = 'dor-services version 7.0.0'
6
8
 
7
9
  # add a file to a resource, not to be confused with add a resource to an object
8
10
  def add_file(file, resource, file_name, mime_type = nil, publish = 'no', shelve = 'no', preserve = 'no')
@@ -10,7 +12,7 @@ module Dor
10
12
  # make sure the resource exists
11
13
  raise 'resource doesnt exist.' if xml.search('//resource[@id=\'' + resource + '\']').length == 0
12
14
 
13
- sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, :auth_methods => ['publickey'])
15
+ sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, auth_methods: ['publickey'])
14
16
  druid_tools = DruidTools::Druid.new(pid, Config.content.content_base_dir)
15
17
  location = druid_tools.path(file_name)
16
18
  oldlocation = location.gsub('/' + pid.gsub('druid:', ''), '')
@@ -18,7 +20,7 @@ module Dor
18
20
  sha1 = Digest::SHA1.file(file.path).hexdigest
19
21
  size = File.size?(file.path)
20
22
  # update contentmd
21
- file_hash = { :name => file_name, :md5 => md5, :publish => publish, :shelve => shelve, :preserve => preserve, :size => size.to_s, :sha1 => sha1, :mime_type => mime_type }
23
+ file_hash = { name: file_name, md5: md5, publish: publish, shelve: shelve, preserve: preserve, size: size.to_s, sha1: sha1, mime_type: mime_type }
22
24
  begin
23
25
  sftp.stat!(location.gsub(file_name, ''))
24
26
  begin
@@ -41,9 +43,10 @@ module Dor
41
43
  end
42
44
  # can only arrive at this point if a non status exception occurred.
43
45
  end
46
+ deprecation_deprecate add_file: 'will be removed without replacement'
44
47
 
45
48
  def replace_file(file, file_name)
46
- sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, :auth_methods => ['publickey'])
49
+ sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, auth_methods: ['publickey'])
47
50
  item = Dor.find(pid)
48
51
  druid_tools = DruidTools::Druid.new(pid, Config.content.content_base_dir)
49
52
  location = druid_tools.path(file_name)
@@ -52,44 +55,47 @@ module Dor
52
55
  sha1 = Digest::SHA1.file(file.path).hexdigest
53
56
  size = File.size?(file.path)
54
57
  # update contentmd
55
- file_hash = { :name => file_name, :md5 => md5, :size => size.to_s, :sha1 => sha1 }
58
+ file_hash = { name: file_name, md5: md5, size: size.to_s, sha1: sha1 }
56
59
  begin
57
60
  sftp.stat!(location)
58
61
  sftp.upload!(file.path, location)
59
62
  # this doesnt allow renaming files
60
63
  item.contentMetadata.update_file(file_hash, file_name)
61
- rescue
64
+ rescue StandardError
62
65
  sftp.upload!(file.path, oldlocation)
63
66
  item.contentMetadata.update_file(file_hash, file_name)
64
67
  end
65
68
  end
69
+ deprecation_deprecate replace_file: 'will be removed without replacement'
66
70
 
67
71
  def get_preserved_file(file, version)
68
72
  Sdr::Client.get_preserved_file_content(pid, file, version)
69
73
  end
74
+ deprecation_deprecate get_preserved_file: 'Use Dor::Services::Client.preserved_content instead'
70
75
 
71
76
  def get_file(file)
72
77
  druid_tools = DruidTools::Druid.new(pid, Config.content.content_base_dir)
73
78
  location = druid_tools.path(file)
74
79
  oldlocation = location.gsub('/' + file, '').gsub('/' + pid.gsub('druid:', ''), '') + '/' + file
75
- sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, :auth_methods => ['publickey'])
80
+ sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, auth_methods: ['publickey'])
76
81
  begin
77
82
  data = sftp.download!(location)
78
- rescue
83
+ rescue StandardError
79
84
  data = sftp.download!(oldlocation)
80
85
  end
81
86
  data
82
87
  end
88
+ deprecation_deprecate get_file: 'use dor-services-app:/v1/objects/:id/contents/*path instead'
83
89
 
84
90
  # @param [String] filename
85
91
  def remove_file(filename)
86
92
  druid_tools = DruidTools::Druid.new(pid, Config.content.content_base_dir)
87
93
  location = druid_tools.path(filename)
88
94
  oldlocation = location.gsub('/' + pid.gsub('druid:', ''), '')
89
- sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, :auth_methods => ['publickey'])
95
+ sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, auth_methods: ['publickey'])
90
96
  begin
91
97
  sftp.remove!(location)
92
- rescue
98
+ rescue StandardError
93
99
  # if the file doesnt exist, that is ok, not all files will be present in the workspace
94
100
  begin
95
101
  sftp.remove!(oldlocation)
@@ -98,6 +104,7 @@ module Dor
98
104
  end
99
105
  contentMetadata.remove_file filename
100
106
  end
107
+ deprecation_deprecate remove_file: 'will be removed without replacement'
101
108
 
102
109
  # @param [String] old_name
103
110
  # @param [String] new_name
@@ -105,14 +112,15 @@ module Dor
105
112
  druid_tools = DruidTools::Druid.new(pid, Config.content.content_base_dir)
106
113
  location = druid_tools.path(old_name)
107
114
  oldlocation = location.gsub('/' + pid.gsub('druid:', ''), '')
108
- sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, :auth_methods => ['publickey'])
115
+ sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, auth_methods: ['publickey'])
109
116
  begin
110
117
  sftp.rename!(location, location.gsub(old_name, new_name))
111
- rescue
118
+ rescue StandardError
112
119
  sftp.rename!(oldlocation, oldlocation.gsub(old_name, new_name))
113
120
  end
114
121
  contentMetadata.rename_file(old_name, new_name)
115
122
  end
123
+ deprecation_deprecate rename_file: 'will be removed without replacement'
116
124
 
117
125
  # @param [String] resource_name ID of the resource elememnt
118
126
  def remove_resource(resource_name)
@@ -123,13 +131,15 @@ module Dor
123
131
  # remove the resource record from the metadata and renumber the resource sequence
124
132
  contentMetadata.remove_resource resource_name
125
133
  end
134
+ deprecation_deprecate remove_resource: 'will be removed without replacement'
126
135
 
136
+ # TODO: Move to Argo
127
137
  # list files in the workspace
128
138
  # @return [Array] workspace files
129
139
  def list_files
130
140
  filename = 'none'
131
141
  files = []
132
- sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, :auth_methods => ['publickey'])
142
+ sftp = Net::SFTP.start(Config.content.content_server, Config.content.content_user, auth_methods: ['publickey'])
133
143
  druid_tools = DruidTools::Druid.new(pid, Config.content.content_base_dir)
134
144
  location = druid_tools.path(filename).gsub(filename, '')
135
145
  oldlocation = location.gsub('/' + pid.gsub('druid:', ''), '')
@@ -137,7 +147,7 @@ module Dor
137
147
  sftp.dir.entries(location, '*') do |file|
138
148
  files << file.name
139
149
  end
140
- rescue
150
+ rescue StandardError
141
151
  begin
142
152
  sftp.dir.glob(oldlocation, '*') do |file|
143
153
  files << file.name
@@ -148,6 +158,7 @@ module Dor
148
158
  end
149
159
  files
150
160
  end
161
+ deprecation_deprecate list_files: 'use dor-services-app:/v1/objects/:id/contents instead'
151
162
 
152
163
  # @param [String] filename
153
164
  # @return [Boolean] whether the file in question is present in the object's workspace
@@ -155,58 +166,7 @@ module Dor
155
166
  druid_obj = DruidTools::Druid.new(pid, Dor::Config.stacks.local_workspace_root)
156
167
  !druid_obj.find_content(filename).nil?
157
168
  end
158
-
159
- # Appends contentMetadata file resources from the source objects to this object
160
- # @param [Array<String>] source_obj_pids ids of the secondary objects that will get their contentMetadata merged into this one
161
- def copy_file_resources(source_obj_pids)
162
- primary_cm = contentMetadata.ng_xml
163
- contentMetadata.ng_xml_will_change!
164
- base_id = primary_cm.at_xpath('/contentMetadata/@objectId').value
165
- max_sequence = primary_cm.at_xpath('/contentMetadata/resource[last()]/@sequence').value.to_i
166
-
167
- source_obj_pids.each do |src_pid|
168
- source_obj = Dor.find src_pid
169
- source_cm = source_obj.contentMetadata.ng_xml
170
-
171
- # Copy the resources from each source object
172
- source_cm.xpath('/contentMetadata/resource').each do |old_resource|
173
- max_sequence += 1
174
- resource_copy = old_resource.clone
175
- resource_copy['sequence'] = "#{max_sequence}"
176
-
177
- # Append sequence number to each secondary filename, then
178
- # look for filename collisions with the primary object
179
- resource_copy.xpath('file').each do |secondary_file|
180
- secondary_file['id'] = new_secondary_file_name(secondary_file['id'], max_sequence)
181
-
182
- if primary_cm.at_xpath("//file[@id = '#{secondary_file['id']}']")
183
- raise Dor::Exception, "File '#{secondary_file['id']}' from secondary object #{src_pid} already exist in primary object: #{pid}"
184
- end
185
- end
186
-
187
- if old_resource['type']
188
- resource_copy['id'] = "#{old_resource['type']}_#{max_sequence}"
189
- else
190
- resource_copy['id'] = "#{base_id}_#{max_sequence}"
191
- end
192
-
193
- lbl = old_resource.at_xpath 'label'
194
- if lbl && lbl.text =~ /^(.*)\s+\d+$/
195
- resource_copy.at_xpath('label').content = "#{$1} #{max_sequence}"
196
- end
197
-
198
- primary_cm.at_xpath('/contentMetadata/resource[last()]').add_next_sibling resource_copy
199
- attr_node = primary_cm.create_element 'attr', src_pid, :name => 'mergedFromPid'
200
- resource_copy.first_element_child.add_previous_sibling attr_node
201
- attr_node = primary_cm.create_element 'attr', old_resource['id'], :name => 'mergedFromResource'
202
- resource_copy.first_element_child.add_previous_sibling attr_node
203
- end
204
- end
205
- end
206
-
207
- def new_secondary_file_name(old_name, sequence_num)
208
- old_name =~ /^(.*)\.(.*)$/ ? "#{$1}_#{sequence_num}.#{$2}" : "#{old_name}_#{sequence_num}"
209
- end
169
+ deprecation_deprecate is_file_in_workspace?: 'will be removed without replacement'
210
170
 
211
171
  # Clears RELS-EXT relationships, sets the isGovernedBy relationship to the SDR Graveyard APO
212
172
  # @param [String] tag optional String of text that is concatenated to the identityMetadata/tag "Decommissioned : "
@@ -223,12 +183,10 @@ module Dor
223
183
  contentMetadata.content = '<contentMetadata/>'
224
184
  # eliminate rightsMetadata. set it to <rightsMetadata/> ?
225
185
  rightsMetadata.content = '<rightsMetadata/>'
226
- add_tag "Decommissioned : #{tag}"
186
+ TagService.add self, "Decommissioned : #{tag}"
227
187
  end
228
188
 
229
- alias_method :decomission, :decommission
230
- deprecate decomission: 'Use decommission instead'
231
-
189
+ # TODO: Move to Dor-Utils.
232
190
  # Adds a RELS-EXT constituent relationship to the given druid
233
191
  # @param [String] druid the parent druid of the constituent relationship
234
192
  # e.g.: <fedora:isConstituentOf rdf:resource="info:fedora/druid:hj097bm8879" />
@@ -3,15 +3,11 @@
3
3
  module Dor
4
4
  module Describable
5
5
  extend ActiveSupport::Concern
6
-
7
- MODS_TO_DC_XSLT = Nokogiri::XSLT(File.new(File.expand_path(File.dirname(__FILE__) + "/mods2dc.xslt")))
8
- XMLNS_OAI_DC = 'http://www.openarchives.org/OAI/2.0/oai_dc/'
9
- XMLNS_DC = 'http://purl.org/dc/elements/1.1/'
10
-
11
- class CrosswalkError < Exception; end
6
+ extend Deprecation
7
+ self.deprecation_horizon = 'dor-services version 7.0.0'
12
8
 
13
9
  included do
14
- has_metadata :name => 'descMetadata', :type => Dor::DescMetadataDS, :label => 'Descriptive Metadata', :control_group => 'M'
10
+ has_metadata name: 'descMetadata', type: Dor::DescMetadataDS, label: 'Descriptive Metadata', control_group: 'M'
15
11
  end
16
12
 
17
13
  require 'stanford-mods'
@@ -29,7 +25,7 @@ module Dor
29
25
  end
30
26
 
31
27
  def fetch_descMetadata_datastream
32
- candidates = datastreams['identityMetadata'].otherId.collect { |oid| oid.to_s }
28
+ candidates = datastreams['identityMetadata'].otherId.collect(&:to_s)
33
29
  metadata_id = Dor::MetadataService.resolvable(candidates).first
34
30
  metadata_id.nil? ? nil : Dor::MetadataService.fetch(metadata_id.to_s)
35
31
  end
@@ -49,40 +45,29 @@ module Dor
49
45
  # @raise [CrosswalkError] Raises an Exception if the generated DC is empty or has no children
50
46
  # @return [Nokogiri::Doc] the DublinCore XML document object
51
47
  def generate_dublin_core(include_collection_as_related_item: true)
52
- desc_md = if include_collection_as_related_item
53
- Nokogiri::XML(generate_public_desc_md(include_access_conditions: false))
54
- else
55
- descMetadata.ng_xml
56
- end
57
-
58
- dc_doc = MODS_TO_DC_XSLT.transform(desc_md)
59
- dc_doc.xpath('/oai_dc:dc/*[count(text()) = 0]', oai_dc: XMLNS_OAI_DC).remove # Remove empty nodes
60
- raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml (no root):\n#{dc_doc.to_xml}" if dc_doc.root.nil?
61
- raise CrosswalkError, "Dor::Item#generate_dublin_core produced incorrect xml (no children):\n#{dc_doc.to_xml}" if dc_doc.root.children.size == 0
62
-
63
- dc_doc
48
+ DublinCoreService.new(self, include_collection_as_related_item: include_collection_as_related_item).to_xml
64
49
  end
50
+ deprecation_deprecate generate_dublin_core: 'Use DublinCoreService#to_xml instead'
65
51
 
66
52
  # @return [String] Public descriptive medatada XML
67
53
  def generate_public_desc_md(**options)
68
54
  PublicDescMetadataService.new(self).to_xml(**options)
69
55
  end
56
+ deprecation_deprecate generate_public_desc_md: 'Use PublicDescMetadataService#to_xml instead'
70
57
 
71
58
  # @param [Boolean] force Overwrite existing XML
72
59
  # @return [String] descMetadata.content XML
73
60
  def set_desc_metadata_using_label(force = false)
74
- unless force || descMetadata.new?
75
- raise 'Cannot proceed, there is already content in the descriptive metadata datastream: ' + descMetadata.content.to_s
76
- end
61
+ raise 'Cannot proceed, there is already content in the descriptive metadata datastream: ' + descMetadata.content.to_s unless force || descMetadata.new?
77
62
 
78
63
  label = self.label
79
- builder = Nokogiri::XML::Builder.new { |xml|
80
- xml.mods(Dor::DescMetadataDS::MODS_HEADER_CONFIG) {
81
- xml.titleInfo {
64
+ builder = Nokogiri::XML::Builder.new do |xml|
65
+ xml.mods(Dor::DescMetadataDS::MODS_HEADER_CONFIG) do
66
+ xml.titleInfo do
82
67
  xml.title label
83
- }
84
- }
85
- }
68
+ end
69
+ end
70
+ end
86
71
  descMetadata.content = builder.to_xml
87
72
  end
88
73