-
Notifications
You must be signed in to change notification settings - Fork 2
/
sdr_controller.rb
51 lines (39 loc) · 1.6 KB
/
sdr_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# frozen_string_literal: true
class SdrController < ApplicationController
def cm_inv_diff
unless %w(all shelve preserve publish).include?(params[:subset].to_s)
render status: :bad_request, plain: "Invalid subset value: #{params[:subset]}"
return
end
request.body.rewind
current_content = request.body.read
query_params = { subset: params[:subset].to_s }
query_params[:version] = params[:version].to_s unless params[:version].nil?
query_string = URI.encode_www_form(query_params)
url = "#{Settings.sdr_url}/objects/#{params[:druid]}/cm-inv-diff?#{query_string}"
sdr_response = Faraday.post(url, current_content, 'Content-Type' => 'application/xml')
proxy_faraday_response(sdr_response)
end
def ds_manifest
url = "#{Settings.sdr_url}/objects/#{params[:druid]}/manifest/#{params[:dsname]}"
sdr_response = Faraday.get url
proxy_faraday_response(sdr_response)
end
def ds_metadata
url = "#{Settings.sdr_url}/objects/#{params[:druid]}/metadata/#{params[:dsname]}"
sdr_response = Faraday.get url
proxy_faraday_response(sdr_response)
end
def current_version
url = "#{Settings.sdr_url}/objects/#{params[:druid]}/current_version"
sdr_response = Faraday.get url
proxy_faraday_response(sdr_response)
end
def file_content
query_string = URI.encode_www_form(version: params[:version].to_s)
encoded_filename = URI.encode(params[:filename])
url = "#{Settings.sdr_url}/objects/#{params[:druid]}/content/#{encoded_filename}?#{query_string}"
sdr_response = Faraday.get url
proxy_faraday_response(sdr_response)
end
end