-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6020 from avalonmediasystem/mo_index_groups
Override RSolr::Client to fallback to ActiveFedora#default_http_method
- Loading branch information
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
RSolr::Client.class_eval do | ||
def build_request path, opts | ||
raise "path must be a string or symbol, not #{path.inspect}" unless [String,Symbol].include?(path.class) | ||
path = path.to_s | ||
opts[:proxy] = proxy unless proxy.nil? | ||
# Avalon can produce requests that are too large for :get. | ||
# Override method to use configurable http method to avoid | ||
# having to override every instance that calls RSolr directly. | ||
opts[:method] ||= ActiveFedora::SolrService.default_http_method | ||
raise "The :data option can only be used if :method => :post" if opts[:method] != :post and opts[:data] | ||
opts[:params] = params_with_wt(opts[:params]) | ||
query = RSolr::Uri.params_to_solr(opts[:params]) unless opts[:params].empty? | ||
opts[:query] = query | ||
if opts[:data].is_a? Hash | ||
opts[:data] = RSolr::Uri.params_to_solr opts[:data] | ||
opts[:headers] ||= {} | ||
opts[:headers]['Content-Type'] ||= 'application/x-www-form-urlencoded; charset=UTF-8' | ||
end | ||
opts[:path] = path | ||
opts[:uri] = base_uri.merge(path.to_s + (query ? "?#{query}" : "")) if base_uri | ||
|
||
opts | ||
end | ||
end |