Skip to content

Commit

Permalink
deprecate API endpoint sdr#cm-inv-diff and SdrClient.content_diff
Browse files Browse the repository at this point in the history
  • Loading branch information
ndushay committed Dec 6, 2019
1 parent ddac205 commit eba3786
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions app/controllers/sdr_controller.rb
Expand Up @@ -5,6 +5,8 @@ class SdrController < ApplicationController
self.deprecation_horizon = 'dor-services-app version 4.0'

def cm_inv_diff
dep_msg = 'Use preservation-client content_inventory_diff or shelve_content_diff in caller instead.'
Honeybadger.notify("dor-services-app deprecated API endpoint `sdr#cm_inv_diff` called. #{dep_msg}")
unless %w(all shelve preserve publish).include?(params[:subset])
render status: :bad_request, plain: "Invalid subset value: #{params[:subset]}"
return
Expand All @@ -16,6 +18,7 @@ def cm_inv_diff
sdr_response = sdr_client.content_diff(current_content: current_content, subset: params[:subset], version: params[:version])
proxy_faraday_response(sdr_response)
end
deprecation_deprecate cm_inv_diff: 'Use preservation-client content_inventory_diff or shelve_content_diff in caller instead.'

# Deprecated
def ds_manifest
Expand Down
2 changes: 2 additions & 0 deletions app/services/sdr_client.rb
Expand Up @@ -17,13 +17,15 @@ def initialize(druid)

# @return [Faraday::Response] with body of cm-inv-diff as xml
def content_diff(current_content:, subset:, version: nil)
Honeybadger.notify('dor-services-app deprecated method `SdrClient.content_diff` called. Use preservation-client content_diff instead.')
query_params = { subset: subset }
query_params[:version] = version unless version.nil?
query_string = URI.encode_www_form(query_params)
path = "/objects/#{druid}/cm-inv-diff"
uri = sdr_uri(path)
sdr_conn(uri).post("#{uri.path}?#{query_string}", current_content, 'Content-Type' => 'application/xml')
end
deprecation_deprecate content_diff: 'Use preservation-client content_inventory_diff or shelve_content_diff in caller instead.'

def manifest(ds_name:)
sdr_get("/objects/#{druid}/manifest/#{ds_name}")
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -11,7 +11,7 @@
get '/about' => 'ok_computer/ok_computer#show', defaults: { check: 'version' }

scope '/sdr/objects/:druid' do
post 'cm-inv-diff', to: 'sdr#cm_inv_diff'
post 'cm-inv-diff', to: 'sdr#cm_inv_diff' # deprecated; caller should use preservation-client
get 'current_version', to: 'sdr#current_version' # deprecated; caller should use preservation-client
get 'manifest/:dsname', to: 'sdr#ds_manifest', format: false, constraints: { dsname: /.+/ } # deprecated
get 'metadata/:dsname', to: 'sdr#ds_metadata', format: false, constraints: { dsname: /.+/ }
Expand Down
4 changes: 2 additions & 2 deletions openapi.json
Expand Up @@ -75,8 +75,8 @@
"tags": [
"preservation"
],
"summary": "Get the diff of the content metadata from DOR and SDR",
"description": "",
"summary": "DEPRECATED. Get the diff between content metadata provided and version in preservation",
"description": "DEPRECATED. Use preservation-client gem instead.",
"operationId": "sdr#cm_inv_diff",
"responses": {
"200": {
Expand Down

0 comments on commit eba3786

Please sign in to comment.