preservation-client 3.2.1 → 3.3.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: 346519c8c530b30507578d91469ffd1f50cf08fe3b6b5f5e46905f35e6d870ab
4
- data.tar.gz: 38afa1c113b86737ac3593101b3bfc1133de42bc58398de19250636bbdbefc05
3
+ metadata.gz: 295c6b5719f6730587b25339215cb69a2a0577c83bb703cc0bc17bb0372b64e3
4
+ data.tar.gz: 26c60ca8f89488ed4d8e9ee301fb1632727ddb852ddaf4f2db796cf97f0a51f3
5
5
  SHA512:
6
- metadata.gz: 81c98f1a410de28f6c8bf90dff39c5537670aa4c8ce4625779d21bd8fbbe3c6341a0930f0fc8572a417d6fd1bd5cba4d69586deb402cf8d9d70e695114138306
7
- data.tar.gz: 38e22150bc23cf59501893becb24a39c98eb51d8ac12b5acad80f0a8ad108381a6d9cf88a5f1120a32e9388cfc36c0d1e1dfea5c6cf8b3cf42de74e2c6bda5d7
6
+ metadata.gz: 9d715a4987ea8c1091ba263eed8975feb66ab15e58669011860376a43ce7c80f7bbf771701f4416e9309fe7fb1dfa08e7986c0d7bf556bab939eab419e4c3fae
7
+ data.tar.gz: 2f27d27f5c0c02b0a9fb18943e5c25228e6e6d0f5ca24e190da9d7de20146f8f80d437f1351f659a627178ea52933c185aea811dcad6eff82586d6977ff6e733
@@ -17,13 +17,18 @@ module Preservation
17
17
  class Client
18
18
  class Error < StandardError; end
19
19
 
20
- # Error that is raised when the remote server returns a 404 Not Found
20
+ # Error raised when server returns 404 Not Found
21
21
  class NotFoundError < Error; end
22
22
 
23
- # Error that is raised when the remote server returns some unexpected response
24
- # e.g. 4xx or 5xx status
23
+ # Error raised when server returns 423 Locked
24
+ class LockedError < Error; end
25
+
26
+ # Error raised when server returns an unexpected response
27
+ # e.g., 4xx or 5xx status not otherwise handled
25
28
  class UnexpectedResponseError < Error; end
26
29
 
30
+ # Error raised when Faraday gem fails to connect, e.g., on SSL errors or
31
+ # timeouts
27
32
  class ConnectionFailedError < Error; end
28
33
 
29
34
  DEFAULT_API_VERSION = 'v1'
@@ -75,6 +75,7 @@ module Preservation
75
75
  # @param [String] druid - with or without prefix: 'druid:ab123cd4567' or 'ab123cd4567'
76
76
  # @return [String] the storage location of the primary moab for the given druid
77
77
  # @raise [Preservation::Client::NotFoundError] when druid is not found
78
+ # @raise [Preservation::Client::LockedError] when druid is in locked state (not available for versioning)
78
79
  def primary_moab_location(druid:)
79
80
  get("objects/#{druid}/primary_moab_location", {}, on_data: nil)
80
81
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Preservation
4
4
  class Client
5
- VERSION = '3.2.1'
5
+ VERSION = '3.3.0'
6
6
  end
7
7
  end
@@ -25,14 +25,14 @@ module Preservation
25
25
 
26
26
  errmsg = ResponseErrorFormatter
27
27
  .format(response: resp, object_id: object_id, client_method_name: caller_locations.first.label)
28
- raise Preservation::Client::UnexpectedResponseError, errmsg
28
+ raise UnexpectedResponseError, errmsg
29
29
  rescue Faraday::ResourceNotFound
30
30
  errmsg = "#{object_id} not found in Preservation at #{connection.url_prefix}#{req_url}"
31
- raise Preservation::Client::NotFoundError, errmsg
31
+ raise NotFoundError, errmsg
32
32
  rescue Faraday::Error => e
33
33
  errmsg = "Preservation::Client.#{caller_locations.first.label} for #{object_id} " \
34
34
  "got #{e.response[:status]} from Preservation at #{req_url}: #{e.response[:body]}"
35
- raise Preservation::Client::UnexpectedResponseError, errmsg
35
+ raise UnexpectedResponseError, errmsg
36
36
  end
37
37
 
38
38
  # @param path [String] path to be appended to connection url (no leading slash)
@@ -83,18 +83,20 @@ module Preservation
83
83
  request_json = params.to_json if params&.any?
84
84
  connection.public_send(method, req_url, request_json, 'Content-Type' => 'application/json')
85
85
  end
86
+
86
87
  return resp.body if resp.success?
87
88
 
88
89
  errmsg = ResponseErrorFormatter.format(response: resp, client_method_name: caller_locations.first.label)
89
- raise Preservation::Client::UnexpectedResponseError, errmsg
90
+ raise UnexpectedResponseError, errmsg
90
91
  rescue Faraday::ResourceNotFound => e
91
92
  errmsg = "Preservation::Client.#{caller_locations.first.label} " \
92
93
  "got #{e.response[:status]} from Preservation at #{req_url}: #{e.response[:body]}"
93
- raise Preservation::Client::NotFoundError, errmsg
94
+ raise NotFoundError, errmsg
94
95
  rescue Faraday::Error => e
95
96
  errmsg = "Preservation::Client.#{caller_locations.first.label} " \
96
97
  "got #{e.response[:status]} from Preservation at #{req_url}: #{e.response[:body]}"
97
- raise Preservation::Client::UnexpectedResponseError, errmsg
98
+ exception_class = e.response[:status] == 423 ? LockedError : UnexpectedResponseError
99
+ raise exception_class, errmsg
98
100
  end
99
101
  end
100
102
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: preservation-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-25 00:00:00.000000000 Z
11
+ date: 2020-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -225,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
225
  - !ruby/object:Gem::Version
226
226
  version: '0'
227
227
  requirements: []
228
- rubygems_version: 3.1.2
228
+ rubygems_version: 3.0.6
229
229
  signing_key:
230
230
  specification_version: 4
231
231
  summary: A thin client for getting info from SDR preservation.