dor-services-client 1.5.0 → 1.5.1

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: dd0e89756c5a456653886f4a0e502a08b71e2dfec3d898e698d02299a96768d4
4
- data.tar.gz: b27e3fde33c638dc7b4ed56ec629c3fd585bef42992391257b885fb5bd18d61c
3
+ metadata.gz: 11f4dfdf374726956bc74b43f5963af395401a18caf799bf4d03d4e5df8c9c2d
4
+ data.tar.gz: 5f300197aaff93c4fecf8ba8567246abd36b89af672eb9498fdbebe5f7073fd2
5
5
  SHA512:
6
- metadata.gz: 20819d9efbff8652b0539387d198f17e1f889426d06863bd753cb4411c8bd36e64e39e52f7bb5ee589e72d1cfe86779e52bf981fad598c1521e2ea9a0db65e34
7
- data.tar.gz: 83158ffad56953cd19615b2e2f4e5d2dbc5599634755a09ae543d005a15c6b4f4910bc0ea3ebf07bd14ab8746e21e36b61e5569f65ad9923ecd20115beefa096
6
+ metadata.gz: 4d4c11288cdf203e172279a17b60243b8c6f52043db891002d79b3bfc3acd59e329e5f9a85eb375ca46c9155a902fee407b2682306faa2e3f2c3ab9ac27057ed
7
+ data.tar.gz: de6d4b80acb9e253847ed553f7a0d816e4c65f223996246ab1e7bd8ec85fbe1c05625148f08367afe423c4f206f6c60238643bd541a60a3811fd662109b051fd
data/README.md CHANGED
@@ -67,8 +67,11 @@ object_client.files.retrieve(filename: filename_string)
67
67
  object_client.files.preserved_content(filename: filename_string, version: version_string)
68
68
  object_client.files.list
69
69
  object_client.release_tags.create(release: release, what: what, to: to, who: who)
70
+ object_client.sdr.content_diff(current_content: existing_content)
70
71
  object_client.sdr.current_version
72
+ object_client.sdr.metadata(datastream: dsid)
71
73
  object_client.sdr.signature_catalog
74
+
72
75
  object_client.workflow.create(wf_name: workflow_name_string)
73
76
  object_client.workspace.create(source: object_path_string)
74
77
 
@@ -31,10 +31,9 @@ module Dor
31
31
  end
32
32
 
33
33
  def signature_catalog
34
- resp = connection.get do |req|
35
- req.url "#{base_path}/manifest/signatureCatalog.xml"
36
- end
34
+ resp = signature_catalog_response
37
35
 
36
+ return Moab::SignatureCatalog.new(digital_object_id: object_identifier, version_id: 0) if resp.status == 404
38
37
  raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body}) for #{object_identifier}" unless resp.success?
39
38
 
40
39
  Moab::SignatureCatalog.parse resp.body
@@ -49,16 +48,9 @@ module Dor
49
48
  def content_diff(current_content:, subset: 'all', version: nil)
50
49
  raise ArgumentError, "Invalid subset value: #{subset}" unless %w[all shelve preserve publish].include?(subset)
51
50
 
52
- query_string = { subset: subset }
53
- query_string[:version] = version.to_s unless version.nil?
54
- query_string = URI.encode_www_form(query_string)
51
+ resp = content_diff_response(current_content: current_content, subset: subset, version: version)
55
52
 
56
- resp = connection.post do |req|
57
- req.url "#{base_path}/cm-inv-diff?#{query_string}"
58
- req.headers['Content-Type'] = 'application/xml'
59
- req.body = current_content
60
- end
61
- Moab::FileInventoryDifference.parse(resp.body)
53
+ Moab::FileInventoryDifference.parse(resp)
62
54
  end
63
55
 
64
56
  # @param [String] datastream The identifier of the metadata datastream
@@ -77,6 +69,12 @@ module Dor
77
69
 
78
70
  attr_reader :object_identifier
79
71
 
72
+ def signature_catalog_response
73
+ connection.get do |req|
74
+ req.url "#{base_path}/manifest/signatureCatalog.xml"
75
+ end
76
+ end
77
+
80
78
  # make the request to the server for the currentVersion xml
81
79
  # @raises [UnexpectedResponse] on an unsuccessful response from the server
82
80
  # @returns [String] the raw xml from the server
@@ -93,6 +91,27 @@ module Dor
93
91
  "#{base_path}/current_version"
94
92
  end
95
93
 
94
+ # make the request to the server for the content diff
95
+ # @raises [UnexpectedResponse] on an unsuccessful response from the server
96
+ # @returns [String] the raw xml from the server
97
+ def content_diff_response(current_content:, subset:, version:)
98
+ resp = connection.post do |req|
99
+ req.url content_diff_path(subset: subset, version: version)
100
+ req.headers['Content-Type'] = 'application/xml'
101
+ req.body = current_content
102
+ end
103
+ raise UnexpectedResponse, "#{resp.reason_phrase}: #{resp.status} (#{resp.body}) for #{object_identifier}" unless resp.success?
104
+
105
+ resp.body
106
+ end
107
+
108
+ def content_diff_path(subset:, version:)
109
+ query_string = { subset: subset }
110
+ query_string[:version] = version.to_s unless version.nil?
111
+ query_string = URI.encode_www_form(query_string)
112
+ "#{base_path}/cm-inv-diff?#{query_string}"
113
+ end
114
+
96
115
  def base_path
97
116
  "#{api_version}/sdr/objects/#{object_identifier}"
98
117
  end
@@ -3,7 +3,7 @@
3
3
  module Dor
4
4
  module Services
5
5
  class Client
6
- VERSION = '1.5.0'
6
+ VERSION = '1.5.1'
7
7
  end
8
8
  end
9
9
  end
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: 1.5.0
4
+ version: 1.5.1
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-02-08 00:00:00.000000000 Z
12
+ date: 2019-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport