app/controllers/resolve_controller.rb in umlaut-3.3.1 vs app/controllers/resolve_controller.rb in umlaut-4.0.0.beta1
- old
+ new
@@ -18,11 +18,13 @@
after_filter :save_request
layout :resolve_layout, :except => [:partial_html_sections]
def index
- self.service_dispatch()
+ # saving the bg Thread object mostly so testing environment
+ # can wait on it.
+ @bg_thread = self.service_dispatch()
# check for menu skipping configuration. link is a ServiceResponse
link = should_skip_menu
if ( ! link.nil? )
redirect_to url_for(:controller => "link_router",
:action => "index",
@@ -47,32 +49,11 @@
render :json => {:permalink => current_permalink_url}
end
end
end
- # inputs an OpenURL request into the system and stores it, but does
- # NOT actually dispatch services to provide a response. Will usually
- # be called by software, not a human browser. Sometimes
- # it's useful to do this as a first step before redirecting the user
- # to the actual resolve action for the supplied request--for instance,
- # when the OpenURL metadata comes in a POST and can't be redirected.
- def register_request
- # init before filter already took care of setting up the request.
- @user_request.save!
-
- # Return data in headers allowing client to redirect user
- # to view actual response.
- headers["x-umlaut-request_id"] = @user_request.id
- headers["x-umlaut-resolve_url"] = url_for( :controller => 'resolve', 'umlaut.request_id'.to_sym => @user_request.id )
- headers["x-umlaut-permalink_url"] = current_permalink_url()
-
- # Return empty body. Once we have the xml response done,
- # this really ought to return an xml response, but with
- # no service responses yet available.
- render(:nothing => true)
- end
-
+
# Useful for developers, generate a coins. Start from
# search/journals?umlaut.display_coins=true
# or search/books?umlaut.display_coins=true
def display_coins
end
@@ -127,16 +108,22 @@
self.service_dispatch()
@user_request.save!
api_render()
end
- def rescue_action_in_public(exception)
- render(:template => "error/resolve_error", :status => 500 )
+ # Not an action method. Used only in test environment, get the Thread object executing
+ # background services, so you can #join on it to wait for bg
+ # services to complete.
+ def bg_thread
+ @bg_thread
end
+
protected
+
+
def post_to_get
if request.method == "POST"
redirect_to url_for(params)
end
end
@@ -153,11 +140,11 @@
# We have to clean the params of bad char encoding bytes, or it causes
# no end of problems later. We can't just refuse to process, sources
# do send us bad bytes, I'm afraid.
params.values.each do |v|
- EnsureValidEncoding.ensure_valid_encoding!(v, :invalid => :replace)
+ v.scrub!
end
# Create an UmlautRequest object.
options = {}
if ( @@no_create_request_actions.include?(params[:action]) )
options[:allow_create] = false
@@ -199,13 +186,10 @@
rfr_id = @user_request.referrer_id
return nil if exclude_rfr_ids != nil && exclude_rfr_ids.find {|i| i == rfr_id}
# Services to skip for?
skip[:service_types].each do | service |
service = ServiceTypeValue[service] unless service.kind_of?(ServiceTypeValue)
- candidates =
- @user_request.service_responses.find(:all,
- :conditions => ["service_type_value_name = ?", service.name])
- return_value = candidates.first
+ return_value = @user_request.service_responses.where(:service_type_value_name => service.name).first
end
# But wait, make sure it's included in :services if present.
if (return_value && skip[:services] )
return_value = nil unless skip[:services].include?( return_value.service_id )
\ No newline at end of file