Class: Sdr::Client
- Inherits:
-
Object
- Object
- Sdr::Client
- Extended by:
- Deprecation
- Defined in:
- lib/dor/utils/sdr_client.rb
Class Method Summary collapse
- .client ⇒ Object
-
.current_version(druid) ⇒ Integer
The current version from SDR.
-
.get_content_diff(druid, current_content, subset = 'all', version = nil) ⇒ Moab::FileInventoryDifference
Retrieves file difference manifest for contentMetadata from SDR.
-
.get_preserved_file_content(druid, filename, version) ⇒ Object
This is used by Argo.
-
.get_sdr_metadata(druid, dsname) ⇒ String
The datastream contents from the previous version of the digital object (fetched from SDR storage).
-
.get_signature_catalog(druid) ⇒ Moab::SignatureCatalog
The catalog of all files previously ingested.
Class Method Details
.client ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/dor/utils/sdr_client.rb', line 70 def client if Dor::Config.sdr.url # dor-services-app takes this path Dor::Config.sdr.rest_client elsif Dor::Config.dor_services.url # Anything that is not dor-servics-app should be through here. Deprecation.warn(self, 'you are using dor-services to invoke calls to dor-services-app. Use dor-services-client instead.') Dor::Config.dor_services.rest_client['v1/sdr'] else raise Dor::ParameterError, 'Missing Dor::Config.sdr and/or Dor::Config.dor_services configuration' end end |
.current_version(druid) ⇒ Integer
Returns the current version from SDR.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/dor/utils/sdr_client.rb', line 11 def current_version(druid) xml = client["objects/#{druid}/current_version"].get begin doc = Nokogiri::XML xml raise if doc.root.name != 'currentVersion' return Integer(doc.text) rescue StandardError raise "Unable to parse XML from SDR current_version API call: #{xml}" end end |
.get_content_diff(druid, current_content, subset = 'all', version = nil) ⇒ Moab::FileInventoryDifference
Retrieves file difference manifest for contentMetadata from SDR
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dor/utils/sdr_client.rb', line 48 def get_content_diff(druid, current_content, subset = 'all', version = nil) unless subset.is_a? String Deprecation.warn(self, "subset parameter must be a string. You provided '#{subset.inspect}'. This will be an error in version 7") subset = subset.to_s end raise Dor::ParameterError, "Invalid subset value: #{subset}" unless %w(all shelve preserve publish).include?(subset) query_string = { subset: subset } query_string[:version] = version.to_s unless version.nil? query_string = URI.encode_www_form(query_string) sdr_query = "objects/#{druid}/cm-inv-diff?#{query_string}" response = client[sdr_query].post(current_content, content_type: 'application/xml') Moab::FileInventoryDifference.parse(response) end |
.get_preserved_file_content(druid, filename, version) ⇒ Object
This is used by Argo
64 65 66 67 68 |
# File 'lib/dor/utils/sdr_client.rb', line 64 def get_preserved_file_content(druid, filename, version) Deprecation.warn(self, 'Sdr::Client.get_preserved_file_content is deprecated and will be removed in dor-services 7. Use Dor::Services::Client.preserved_content instead') client["objects/#{druid}/content/#{URI.encode(filename)}?version=#{version}"].get end |
.get_sdr_metadata(druid, dsname) ⇒ String
Returns The datastream contents from the previous version of the digital object (fetched from SDR storage).
26 27 28 29 30 |
# File 'lib/dor/utils/sdr_client.rb', line 26 def (druid, dsname) client["objects/#{druid}/metadata/#{dsname}.xml"].get rescue RestClient::ResourceNotFound nil end |
.get_signature_catalog(druid) ⇒ Moab::SignatureCatalog
Returns the catalog of all files previously ingested.
34 35 36 37 38 39 |
# File 'lib/dor/utils/sdr_client.rb', line 34 def get_signature_catalog(druid) response = client["objects/#{druid}/manifest/signatureCatalog.xml"].get Moab::SignatureCatalog.parse(response) rescue RestClient::ResourceNotFound Moab::SignatureCatalog.new(digital_object_id: druid, version_id: 0) end |