Class: Dor::Services::Client::Transfer

Inherits:
VersionedService show all
Defined in:
lib/dor/services/client/transfer.rb

Overview

API calls that move data around.

Constant Summary

Constants inherited from VersionedService

VersionedService::EXCEPTION_CLASS, VersionedService::JSON_API_MIME_TYPE

Instance Method Summary collapse

Methods inherited from VersionedService

#async_result, #with_querystring

Constructor Details

#initialize(connection:, version:, object_identifier:) ⇒ Transfer

Returns a new instance of Transfer.

Parameters:

  • object_identifier (String)

    the pid for the object



9
10
11
12
# File 'lib/dor/services/client/transfer.rb', line 9

def initialize(connection:, version:, object_identifier:)
  super(connection: connection, version: version)
  @object_identifier = object_identifier
end

Instance Method Details

#preserve(lane_id: nil) ⇒ String

Preserve an object (send to SDR)

Parameters:

  • lane_id (String) (defaults to: nil)

    for prioritization (default or low)

Returns:

  • (String)

    URL from Location response header if no errors

Raises:



53
54
55
56
57
58
59
60
61
# File 'lib/dor/services/client/transfer.rb', line 53

def preserve(lane_id: nil)
  query_string = lane_id ? "?lane-id=#{lane_id}" : ''
  resp = connection.post do |req|
    req.url "#{object_path}/preserve#{query_string}"
  end
  return resp.headers['Location'] if resp.success?

  raise_exception_based_on_response!(resp)
end

#publish(workflow: nil, lane_id: nil) ⇒ String

Publish an object (send to PURL)

Parameters:

  • workflow (String) (defaults to: nil)

    (nil) which workflow to callback to.

  • lane_id (String) (defaults to: nil)

    for prioritization (default or low)

Returns:

  • (String)

    the URL of the background job on dor-service-app

Raises:



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/dor/services/client/transfer.rb', line 20

def publish(workflow: nil, lane_id: nil)
  query_params = [].tap do |params|
    params << "workflow=#{workflow}" if workflow
    params << "lane-id=#{lane_id}" if lane_id
  end
  query_string = query_params.any? ? "?#{query_params.join('&')}" : ''
  publish_path = "#{object_path}/publish#{query_string}"
  resp = connection.post do |req|
    req.url publish_path
  end
  return resp.headers['Location'] if resp.success?

  raise_exception_based_on_response!(resp)
end

#shelve(lane_id: nil) ⇒ boolean

Shelve an object (send to Stacks)

Parameters:

  • lane_id (String) (defaults to: nil)

    for prioritization (default or low)

Returns:

  • (boolean)

    true on success

Raises:



68
69
70
71
72
73
74
75
76
# File 'lib/dor/services/client/transfer.rb', line 68

def shelve(lane_id: nil)
  query_string = lane_id ? "?lane-id=#{lane_id}" : ''
  resp = connection.post do |req|
    req.url "#{object_path}/shelve#{query_string}"
  end
  return resp.headers['Location'] if resp.success?

  raise_exception_based_on_response!(resp)
end

#unpublishString

Unpublish an object (yank from to PURL)

Returns:

  • (String)

    the URL of the background job on dor-service-app

Raises:



39
40
41
42
43
44
45
46
# File 'lib/dor/services/client/transfer.rb', line 39

def unpublish
  resp = connection.post do |req|
    req.url "#{object_path}/unpublish"
  end
  return resp.headers['Location'] if resp.success?

  raise_exception_based_on_response!(resp)
end