dor-services-client 3.9.2 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88bceb8dd278f9e782afb494fc38b72157bad6425c3d2bab9c4c8ce8f51c087d
4
- data.tar.gz: bda8ba7c5f23ec3e9a231f86ad60e615cdea8c5b621709d38038aee1daa45735
3
+ metadata.gz: 5bc4758395797b8e5b89c28b1db1587628728e0983e1f85f2985875b80b1f907
4
+ data.tar.gz: f6e2af51ab5b85c9b5295779f2bb8cf3466deed3016bf9fd281f17657e414919
5
5
  SHA512:
6
- metadata.gz: 6c921f485d6f2ec30550817b5ca6800b7fa73a3397b8a7c288bf25e574f27d2bb0b32858962bcdff79062b5c17b741ef6758b8d2c53201939d0c27e4c1ac9934
7
- data.tar.gz: 3aa62231af7c8caeee3642b2769c7aa91f6b3a280e11dfb0ebd4c6d9a59542ad012be2bfb89706b9cec7a0123937be4589ba5432101ee3aed8682edfdccb7b71
6
+ metadata.gz: ada4de8d9117375cda2225b2491a57f96c599fd44a77273e2c04c85e1b9a75acdbc82e0da641cb7e1cba16f1ee8b4b0e8e3fdf26eb325c1dff2b02b06d9773f5
7
+ data.tar.gz: 14b7d08e789e16c122631b18989786e2e2a44a78f010ce8d943694001786f475a9120bb1341d6f2c4cc6f432ae9d261881a436ad4cd5db90f1f7d3209d98a534
@@ -24,7 +24,6 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_dependency 'activesupport', '>= 4.2', '< 7'
26
26
  spec.add_dependency 'cocina-models', '~> 0.6.0'
27
- spec.add_dependency 'deprecation'
28
27
  spec.add_dependency 'faraday', '~> 0.15'
29
28
  spec.add_dependency 'moab-versioning', '~> 4.0'
30
29
  spec.add_dependency 'nokogiri', '~> 1.8'
@@ -5,9 +5,6 @@ module Dor
5
5
  class Client
6
6
  # API calls relating to files
7
7
  class Files < VersionedService
8
- extend Deprecation
9
- self.deprecation_horizon = 'dor-services-client version 4.0'
10
-
11
8
  # @param object_identifier [String] the pid for the object
12
9
  def initialize(connection:, version:, object_identifier:)
13
10
  super(connection: connection, version: version)
@@ -26,20 +23,6 @@ module Dor
26
23
  resp.body
27
24
  end
28
25
 
29
- # Get the preserved file contents
30
- # @param [String] filename the name of the file to retrieve
31
- # @param [Integer] version the version of the file to retrieve
32
- # @return [String] the file contents from the SDR
33
- def preserved_content(filename:, version:)
34
- resp = connection.get do |req|
35
- req.url "#{api_version}/sdr/objects/#{object_identifier}/content/#{CGI.escape(filename)}?version=#{version}"
36
- end
37
- return unless resp.success?
38
-
39
- resp.body
40
- end
41
- deprecation_deprecate preserved_content: 'use preservation-client .content instead'
42
-
43
26
  # Get the list of files in the workspace
44
27
  # @return [Array<String>] the list of filenames in the workspace
45
28
  def list
@@ -15,10 +15,6 @@ module Dor
15
15
  @object_identifier = object_identifier
16
16
  end
17
17
 
18
- def sdr
19
- @sdr ||= SDR.new(parent_params)
20
- end
21
-
22
18
  def metadata
23
19
  @metadata ||= Metadata.new(parent_params)
24
20
  end
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '3.9.2'
6
+ VERSION = '4.0.0'
7
7
  end
8
8
  end
9
9
  end
@@ -3,27 +3,13 @@
3
3
  require 'active_support/core_ext/hash/indifferent_access'
4
4
  require 'active_support/core_ext/module/delegation'
5
5
  require 'active_support/core_ext/object/blank'
6
- require 'deprecation'
7
6
  require 'cocina/models'
8
7
  require 'faraday'
9
8
  require 'singleton'
10
9
  require 'zeitwerk'
11
10
 
12
- class DorServicesClientInflector < Zeitwerk::Inflector
13
- def camelize(basename, _abspath)
14
- case basename
15
- when 'sdr'
16
- 'SDR'
17
- when 'version'
18
- 'VERSION'
19
- else
20
- super
21
- end
22
- end
23
- end
24
-
25
11
  loader = Zeitwerk::Loader.new
26
- loader.inflector = DorServicesClientInflector.new
12
+ loader.inflector = Zeitwerk::GemInflector.new(__FILE__)
27
13
  loader.push_dir(File.absolute_path("#{__FILE__}/../../.."))
28
14
  loader.setup
29
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.9.2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Coyne
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2019-12-12 00:00:00.000000000 Z
12
+ date: 2020-01-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -45,20 +45,6 @@ dependencies:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.6.0
48
- - !ruby/object:Gem::Dependency
49
- name: deprecation
50
- requirement: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :runtime
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
48
  - !ruby/object:Gem::Dependency
63
49
  name: faraday
64
50
  requirement: !ruby/object:Gem::Requirement
@@ -233,7 +219,6 @@ files:
233
219
  - lib/dor/services/client/objects.rb
234
220
  - lib/dor/services/client/release_tags.rb
235
221
  - lib/dor/services/client/response_error_formatter.rb
236
- - lib/dor/services/client/sdr.rb
237
222
  - lib/dor/services/client/version.rb
238
223
  - lib/dor/services/client/versioned_service.rb
239
224
  - lib/dor/services/client/virtual_objects.rb
@@ -1,130 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'nokogiri'
4
- require 'moab'
5
-
6
- module Dor
7
- module Services
8
- class Client
9
- # Deprecated; remove in release 4.0
10
- # API calls that are about preserved objects
11
- class SDR < VersionedService
12
- extend Deprecation
13
- self.deprecation_horizon = 'dor-services-client version 4.0'
14
-
15
- # @param object_identifier [String] the pid for the object
16
- def initialize(connection:, version:, object_identifier:)
17
- super(connection: connection, version: version)
18
- @object_identifier = object_identifier
19
- end
20
-
21
- # Gets the current version number for the object
22
- # @raise [UnexpectedResponse] when the response is not successful.
23
- # @raise [MalformedResponse] when the response is not parseable.
24
- # @return [Integer] the current version
25
- def current_version
26
- xml = current_version_response
27
- begin
28
- doc = Nokogiri::XML xml
29
- raise if doc.root.name != 'currentVersion'
30
-
31
- return Integer(doc.text)
32
- rescue StandardError
33
- raise MalformedResponse, "Unable to parse XML from current_version API call: #{xml}"
34
- end
35
- end
36
- deprecation_deprecate current_version: 'use preservation-client .current_version instead'
37
-
38
- def signature_catalog
39
- resp = signature_catalog_response
40
-
41
- return Moab::SignatureCatalog.new(digital_object_id: object_identifier, version_id: 0) if resp.status == 404
42
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier) unless resp.success?
43
-
44
- Moab::SignatureCatalog.parse resp.body
45
- end
46
- deprecation_deprecate signature_catalog: 'use preservation-client .signature_catalog instead'
47
-
48
- # Retrieves file difference manifest for contentMetadata from SDR
49
- #
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 content_diff(current_content:, subset: 'all', version: nil)
55
- raise ArgumentError, "Invalid subset value: #{subset}" unless %w[all shelve preserve publish].include?(subset)
56
-
57
- resp = content_diff_response(current_content: current_content, subset: subset, version: version)
58
-
59
- Moab::FileInventoryDifference.parse(resp)
60
- end
61
- deprecation_deprecate content_diff: 'use preservation-client .content_inventory_diff instead'
62
-
63
- # @param [String] datastream The identifier of the metadata datastream
64
- # @return [String, NilClass] datastream content from previous version of the object (from SDR storage), or nil if response status is 404
65
- # @raise [UnexpectedResponse] on an unsuccessful, non-404 response from the server
66
- def metadata(datastream:)
67
- resp = connection.get do |req|
68
- req.url "#{base_path}/metadata/#{datastream}.xml"
69
- end
70
- return resp.body if resp.success?
71
- return if resp.status == 404
72
-
73
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
74
- end
75
- deprecation_deprecate metadata: 'use preservation-client .metadata instead'
76
-
77
- private
78
-
79
- attr_reader :object_identifier
80
-
81
- def signature_catalog_response
82
- connection.get do |req|
83
- req.url "#{base_path}/manifest/signatureCatalog.xml"
84
- end
85
- end
86
-
87
- # make the request to the server for the currentVersion xml
88
- # @raise [UnexpectedResponse] on an unsuccessful response from the server
89
- # @return [String] the raw xml from the server
90
- def current_version_response
91
- resp = connection.get do |req|
92
- req.url current_version_path
93
- end
94
- return resp.body if resp.success?
95
-
96
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
97
- end
98
-
99
- def current_version_path
100
- "#{base_path}/current_version"
101
- end
102
-
103
- # make the request to the server for the content diff
104
- # @raise [UnexpectedResponse] on an unsuccessful response from the server
105
- # @return [String] the raw xml from the server
106
- def content_diff_response(current_content:, subset:, version:)
107
- resp = connection.post do |req|
108
- req.url content_diff_path(subset: subset, version: version)
109
- req.headers['Content-Type'] = 'application/xml'
110
- req.body = current_content
111
- end
112
- raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier) unless resp.success?
113
-
114
- resp.body
115
- end
116
-
117
- def content_diff_path(subset:, version:)
118
- query_string = { subset: subset }
119
- query_string[:version] = version.to_s unless version.nil?
120
- query_string = URI.encode_www_form(query_string)
121
- "#{base_path}/cm-inv-diff?#{query_string}"
122
- end
123
-
124
- def base_path
125
- "#{api_version}/sdr/objects/#{object_identifier}"
126
- end
127
- end
128
- end
129
- end
130
- end