dor-services-client 15.31.0 → 15.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/dor/services/client/object_version.rb +10 -4
- data/lib/dor/services/client/version.rb +1 -1
- data/lib/dor/services/client/versioned_service.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '06370387f51516d2a08d643598cc2e885f783014aa3bcb4f353abd131372470e'
|
|
4
|
+
data.tar.gz: 218e00a0664bb35a8ce93677791f6c5d6c52ffb64e3eb23a88da2713a4e79ee6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 37fc5d5a48b56cfa1bab49622d8c63014776f6493252ca7c69d63605296c8b4a60ea4739f0cb9205989a81a6ff37e800b965ba8cf6e35fb9a9f0211719f96ac3
|
|
7
|
+
data.tar.gz: b25369fb1e80f33db2bfc03fb1135f470d882b0af2017b29a3f1342531d5d0c04c0c59f19a8c685519bd89f123b1a9803471204e42f0ad4dd28f6a5339ec9323
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -108,6 +108,8 @@ object_client.version.current
|
|
|
108
108
|
# Status includes whether the object is open, assembling, accessioning, or closeable.
|
|
109
109
|
# See also objects_client.statuses for getting statuses in batch.
|
|
110
110
|
object_client.version.status
|
|
111
|
+
# Returns object version as Cocina instance if valid; returns a Hash<cocina_object:, error_message:> if invalid
|
|
112
|
+
object_client.version.find(3)
|
|
111
113
|
|
|
112
114
|
# see dor-services-app openapi.yml for optional params
|
|
113
115
|
object_client.version.open(description: 'Changed title')
|
|
@@ -53,15 +53,21 @@ module Dor
|
|
|
53
53
|
@object_identifier = object_identifier
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
# @return [Cocina::Models::DROWithMetadata] the object metadata
|
|
57
|
-
#
|
|
56
|
+
# @return [Cocina::Models::DROWithMetadata, Hash] the object metadata or a hash with
|
|
57
|
+
# invalid metadata and a message about the source of the invalidity
|
|
58
|
+
# @raise [Dor::Services::Client::Error] on an unsuccessful response from the server
|
|
58
59
|
def find(version)
|
|
59
60
|
resp = connection.get do |req|
|
|
60
61
|
req.url "#{base_path}/#{version}"
|
|
61
62
|
end
|
|
62
|
-
raise_exception_based_on_response!(resp) unless resp.success?
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
if resp.success?
|
|
65
|
+
build_cocina_from_response(JSON.parse(resp.body), headers: resp.headers, validate: false)
|
|
66
|
+
elsif resp.status == 409 # Signals the Cocina is present but invalid
|
|
67
|
+
build_invalid_cocina_from_response(resp)
|
|
68
|
+
else
|
|
69
|
+
raise_exception_based_on_response!(resp) unless resp.success?
|
|
70
|
+
end
|
|
65
71
|
end
|
|
66
72
|
|
|
67
73
|
# Get the current version for a DOR object. This comes from ObjectVersion table in the DSA
|
|
@@ -54,6 +54,15 @@ module Dor
|
|
|
54
54
|
Cocina::Models.without_metadata(cocina_object).to_json
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
+
def build_invalid_cocina_from_response(response)
|
|
58
|
+
invalid_cocina_error = JSON.parse(response.body).dig('errors', 0)
|
|
59
|
+
|
|
60
|
+
{
|
|
61
|
+
cocina_object: invalid_cocina_error.dig('meta', 'json'),
|
|
62
|
+
error_message: invalid_cocina_error['message']
|
|
63
|
+
}.with_indifferent_access
|
|
64
|
+
end
|
|
65
|
+
|
|
57
66
|
def date_from_header(headers, key)
|
|
58
67
|
headers[key]&.to_datetime
|
|
59
68
|
end
|