Class: Dor::Services::Client::Metadata

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

Overview

API calls that are about retrieving metadata

Instance Method Summary collapse

Methods inherited from VersionedService

#async_result

Constructor Details

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

Returns a new instance of Metadata.

Parameters:

  • object_identifier (String)

    the pid for the object



11
12
13
14
# File 'lib/dor/services/client/metadata.rb', line 11

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

Instance Method Details

#descriptiveString, NilClass

Returns The descriptive metadata XML representation of the object or nil if response is 404.

Returns:

  • (String, NilClass)

    The descriptive metadata XML representation of the object or nil if response is 404

Raises:



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

def descriptive
  resp = connection.get do |req|
    req.url "#{base_path}/descriptive"
  end
  return resp.body if resp.success?
  return if resp.status == 404

  raise_exception_based_on_response!(resp, object_identifier)
end

#dublin_coreString, NilClass

Returns The Dublin Core XML representation of the object or nil if response is 404.

Returns:

  • (String, NilClass)

    The Dublin Core XML representation of the object or nil if response is 404

Raises:



41
42
43
44
45
46
47
48
49
# File 'lib/dor/services/client/metadata.rb', line 41

def dublin_core
  resp = connection.get do |req|
    req.url "#{base_path}/dublin_core"
  end
  return resp.body if resp.success?
  return if resp.status == 404

  raise_exception_based_on_response!(resp, object_identifier)
end

#legacy_update(opts) ⇒ Object

Updates using the legacy SDR/Fedora3 metadata @example:

legacy_update(descriptive: { updated: '2001-12-20', content: '<descMetadata />' })

Parameters:

  • opts (Hash<Symbol,Hash>)

    the options for legacy update

Options Hash (opts):

  • :descriptive (Hash)

    Data for descriptive metadata

  • :rights (Hash)

    Data for access rights metadata

  • :content (Hash)

    Data for structural metadata

  • :identity (Hash)

    Data for identity metadata

  • :technical (Hash)

    Data for technical metadata

  • :provenance (Hash)

    Data for provenance metadata

  • :geo (Hash)

    Data for geographic metadata



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dor/services/client/metadata.rb', line 27

def legacy_update(opts)
  opts = opts.slice(:descriptive, :rights, :identity, :content, :technical, :provenance, :geo)
  resp = connection.patch do |req|
    req.url "#{base_path}/legacy"
    req.headers['Content-Type'] = 'application/json'
    req.body = opts.to_json
  end
  return if resp.success?

  raise_exception_based_on_response!(resp, object_identifier)
end