dor-services 6.8.0 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/config/config_defaults.yml +0 -27
  3. data/config/dev_console_env.rb.example +0 -17
  4. data/lib/dor-services.rb +9 -73
  5. data/lib/dor/config.rb +1 -30
  6. data/lib/dor/datastreams/content_metadata_ds.rb +8 -0
  7. data/lib/dor/datastreams/desc_metadata_ds.rb +19 -0
  8. data/lib/dor/datastreams/identity_metadata_ds.rb +65 -0
  9. data/lib/dor/datastreams/rights_metadata_ds.rb +14 -2
  10. data/lib/dor/datastreams/workflow_definition_ds.rb +1 -1
  11. data/lib/dor/datastreams/workflow_ds.rb +0 -15
  12. data/lib/dor/indexers/identifiable_indexer.rb +8 -4
  13. data/lib/dor/indexers/releasable_indexer.rb +7 -1
  14. data/lib/dor/models/abstract.rb +143 -8
  15. data/lib/dor/models/admin_policy_object.rb +0 -3
  16. data/lib/dor/models/collection.rb +0 -2
  17. data/lib/dor/models/concerns/embargoable.rb +7 -60
  18. data/lib/dor/models/etd.rb +100 -0
  19. data/lib/dor/models/item.rb +12 -28
  20. data/lib/dor/models/part.rb +18 -0
  21. data/lib/dor/models/set.rb +0 -2
  22. data/lib/dor/services/collection_service.rb +36 -0
  23. data/lib/dor/services/embargo_service.rb +93 -0
  24. data/lib/dor/services/ontology.rb +0 -18
  25. data/lib/dor/services/public_desc_metadata_service.rb +7 -11
  26. data/lib/dor/services/search_service.rb +0 -40
  27. data/lib/dor/version.rb +1 -1
  28. data/lib/dor/workflow/document.rb +0 -7
  29. metadata +15 -78
  30. data/lib/dor/models/concerns/assembleable.rb +0 -18
  31. data/lib/dor/models/concerns/contentable.rb +0 -185
  32. data/lib/dor/models/concerns/describable.rb +0 -82
  33. data/lib/dor/models/concerns/eventable.rb +0 -18
  34. data/lib/dor/models/concerns/geoable.rb +0 -14
  35. data/lib/dor/models/concerns/governable.rb +0 -101
  36. data/lib/dor/models/concerns/identifiable.rb +0 -172
  37. data/lib/dor/models/concerns/itemizable.rb +0 -42
  38. data/lib/dor/models/concerns/preservable.rb +0 -46
  39. data/lib/dor/models/concerns/processable.rb +0 -86
  40. data/lib/dor/models/concerns/publishable.rb +0 -76
  41. data/lib/dor/models/concerns/releaseable.rb +0 -118
  42. data/lib/dor/models/concerns/rightsable.rb +0 -25
  43. data/lib/dor/models/concerns/shelvable.rb +0 -15
  44. data/lib/dor/models/concerns/versionable.rb +0 -72
  45. data/lib/dor/services/ability.rb +0 -77
  46. data/lib/dor/services/cleanup_reset_service.rb +0 -103
  47. data/lib/dor/services/datastream_builder.rb +0 -96
  48. data/lib/dor/services/decommission_service.rb +0 -31
  49. data/lib/dor/services/digital_stacks_service.rb +0 -125
  50. data/lib/dor/services/dublin_core_service.rb +0 -45
  51. data/lib/dor/services/file_metadata_merge_service.rb +0 -71
  52. data/lib/dor/services/indexing_service.rb +0 -131
  53. data/lib/dor/services/merge_service.rb +0 -105
  54. data/lib/dor/services/public_xml_service.rb +0 -116
  55. data/lib/dor/services/publish_metadata_service.rb +0 -99
  56. data/lib/dor/services/reset_workspace_service.rb +0 -27
  57. data/lib/dor/services/sdr_ingest_service.rb +0 -172
  58. data/lib/dor/services/secondary_file_name_service.rb +0 -10
  59. data/lib/dor/services/shelving_service.rb +0 -69
  60. data/lib/dor/services/technical_metadata_service.rb +0 -232
  61. data/lib/dor/services/version_service.rb +0 -84
  62. data/lib/dor/utils/sdr_client.rb +0 -94
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Dor
4
- # Open and close versions
5
- class VersionService
6
- def self.open(work, opts = {})
7
- new(work).open(opts)
8
- end
9
-
10
- def self.close(work, opts = {})
11
- new(work).close(opts)
12
- end
13
-
14
- def initialize(work)
15
- @work = work
16
- end
17
-
18
- # Increments the version number and initializes versioningWF for the object
19
- # @param [Hash] opts optional params
20
- # @option opts [Boolean] :assume_accessioned If true, does not check whether object has been accessioned.
21
- # @option opts [Boolean] :create_workflows_ds If false, create_workflow() will not initialize the workflows datastream.
22
- # @option opts [Hash] :vers_md_upd_info If present, used to add to the events datastream and set the desc and significance on the versionMetadata datastream
23
- # @raise [Dor::Exception] if the object hasn't been accessioned, or if a version is already opened
24
- def open(opts = {})
25
- # During local development, we need a way to open a new version even if the object has not been accessioned.
26
- raise(Dor::Exception, 'Object net yet accessioned') unless
27
- opts[:assume_accessioned] || Dor::Config.workflow.client.lifecycle('dor', work.pid, 'accessioned')
28
- raise Dor::VersionAlreadyOpenError, 'Object already opened for versioning' if open?
29
- raise Dor::Exception, 'Object currently being accessioned' if Dor::Config.workflow.client.active_lifecycle('dor', work.pid, 'submitted')
30
-
31
- sdr_version = Sdr::Client.current_version work.pid
32
-
33
- vmd_ds = work.versionMetadata
34
- vmd_ds.sync_then_increment_version sdr_version
35
- vmd_ds.save unless work.new_record?
36
-
37
- k = :create_workflows_ds
38
- if opts.key?(k)
39
- # During local development, Hydrus (or another app w/ local Fedora) does not want to initialize workflows datastream.
40
- CreateWorkflowService.create_workflow(work, name: 'versioningWF', create_ds: opts[k])
41
- else
42
- CreateWorkflowService.create_workflow(work, name: 'versioningWF')
43
- end
44
-
45
- vmd_upd_info = opts[:vers_md_upd_info]
46
- return unless vmd_upd_info
47
-
48
- work.events.add_event('open', vmd_upd_info[:opening_user_name], "Version #{vmd_ds.current_version_id} opened")
49
- vmd_ds.update_current_version(description: vmd_upd_info[:description], significance: vmd_upd_info[:significance].to_sym)
50
- work.save
51
- end
52
-
53
- # Sets versioningWF:submit-version to completed and initiates accessionWF for the object
54
- # @param [Hash] opts optional params
55
- # @option opts [String] :description describes the version change
56
- # @option opts [Symbol] :significance which part of the version tag to increment
57
- # :major, :minor, :admin (see Dor::VersionTag#increment)
58
- # @option opts [String] :version_num version number to archive rows with. Otherwise, current version is used
59
- # @option opts [Boolean] :start_accesion set to true if you want accessioning to start (default), false otherwise
60
- # @raise [Dor::Exception] if the object hasn't been opened for versioning, or if accessionWF has
61
- # already been instantiated or the current version is missing a tag or description
62
- def close(opts = {})
63
- unless opts.empty?
64
- work.versionMetadata.update_current_version opts
65
- work.versionMetadata.save
66
- end
67
-
68
- raise Dor::Exception, 'latest version in versionMetadata requires tag and description before it can be closed' unless work.versionMetadata.current_version_closeable?
69
- raise Dor::Exception, 'Trying to close version on an object not opened for versioning' unless open?
70
- raise Dor::Exception, 'accessionWF already created for versioned object' if Dor::Config.workflow.client.active_lifecycle('dor', work.pid, 'submitted')
71
-
72
- Dor::Config.workflow.client.close_version 'dor', work.pid, opts.fetch(:start_accession, true) # Default to creating accessionWF when calling close_version
73
- end
74
-
75
- # @return [Boolean] true if 'opened' lifecycle is active, false otherwise
76
- def open?
77
- return true if Dor::Config.workflow.client.active_lifecycle('dor', work.pid, 'opened')
78
-
79
- false
80
- end
81
-
82
- attr_reader :work
83
- end
84
- end
@@ -1,94 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'moab'
4
- module Sdr
5
- class Client
6
- extend Deprecation
7
-
8
- class << self
9
- # @param [String] druid id of the object you want the version of
10
- # @return [Integer] the current version from SDR
11
- def current_version(druid)
12
- xml = client["objects/#{druid}/current_version"].get
13
-
14
- begin
15
- doc = Nokogiri::XML xml
16
- raise if doc.root.name != 'currentVersion'
17
-
18
- return Integer(doc.text)
19
- rescue StandardError
20
- raise "Unable to parse XML from SDR current_version API call: #{xml}"
21
- end
22
- end
23
-
24
- # @param [String] dsname The identifier of the metadata datastream
25
- # @return [String] The datastream contents from the previous version of the digital object (fetched from SDR storage)
26
- def get_sdr_metadata(druid, dsname)
27
- Deprecation.warn(self, 'Sdr::Client.get_sdr_metadata is deprecated and will be removed in dor-services 7. ' \
28
- 'Use Dor::Services::Client.object(object_identifier).sdr.metadatra(datastream:) instead')
29
-
30
- client["objects/#{druid}/metadata/#{dsname}.xml"].get
31
- rescue RestClient::ResourceNotFound
32
- nil
33
- end
34
-
35
- # @param [String] druid The object identifier
36
- # @return [Moab::SignatureCatalog] the catalog of all files previously ingested
37
- def get_signature_catalog(druid)
38
- Deprecation.warn(self, 'Sdr::Client.get_signature_catalog is deprecated and will be removed in dor-services 7. ' \
39
- 'Use Dor::Services::Client.object(object_identifier).sdr.signature_catalog instead')
40
-
41
- response = client["objects/#{druid}/manifest/signatureCatalog.xml"].get
42
- Moab::SignatureCatalog.parse(response)
43
- rescue RestClient::ResourceNotFound
44
- Moab::SignatureCatalog.new(digital_object_id: druid, version_id: 0)
45
- end
46
-
47
- # Retrieves file difference manifest for contentMetadata from SDR
48
- #
49
- # @param [String] druid The object identifier
50
- # @param [String] current_content The contentMetadata xml
51
- # @param [String] subset ('all') The keyword for file attributes 'shelve', 'preserve', 'publish'.
52
- # @param [Integer, NilClass] version (nil)
53
- # @return [Moab::FileInventoryDifference] the differences for the given content and subset (i.e.: cm_inv_diff manifest)
54
- def get_content_diff(druid, current_content, subset = 'all', version = nil)
55
- Deprecation.warn(self, 'Sdr::Client.get_content_diff is deprecated and will be removed in dor-services 7. ' \
56
- 'Use Dor::Services::Client.object(object_identifier).sdr.content_diff(current_content:, subset:, version:) instead')
57
-
58
- unless subset.is_a? String
59
- Deprecation.warn(self, "subset parameter must be a string. You provided '#{subset.inspect}'. This will be an error in version 7")
60
- subset = subset.to_s
61
- end
62
- raise Dor::ParameterError, "Invalid subset value: #{subset}" unless %w(all shelve preserve publish).include?(subset)
63
-
64
- query_string = { subset: subset }
65
- query_string[:version] = version.to_s unless version.nil?
66
- query_string = URI.encode_www_form(query_string)
67
- sdr_query = "objects/#{druid}/cm-inv-diff?#{query_string}"
68
- response = client[sdr_query].post(current_content, content_type: 'application/xml')
69
- Moab::FileInventoryDifference.parse(response)
70
- end
71
-
72
- # This was used by Argo but is no longer used anywhere
73
- def get_preserved_file_content(druid, filename, version)
74
- Deprecation.warn(self, 'Sdr::Client.get_preserved_file_content is deprecated and will be removed in dor-services 7. ' \
75
- 'Use Dor::Services::Client.object(object_identifier).files.preserved_content(filename:, version:) instead')
76
-
77
- client["objects/#{druid}/content/#{URI.encode(filename)}?version=#{version}"].get
78
- end
79
-
80
- def client
81
- if Dor::Config.sdr.url
82
- # dor-services-app takes this path
83
- Dor::Config.sdr.rest_client
84
- elsif Dor::Config.dor_services.url
85
- # Anything that is not dor-servics-app should be through here.
86
- Deprecation.warn(self, 'you are using dor-services to invoke calls to dor-services-app. Use dor-services-client instead.')
87
- Dor::Config.dor_services.rest_client['v1/sdr']
88
- else
89
- raise Dor::ParameterError, 'Missing Dor::Config.sdr and/or Dor::Config.dor_services configuration'
90
- end
91
- end
92
- end
93
- end
94
- end