Class: ResolveController

Inherits:
UmlautController show all
Defined in:
app/controllers/resolve_controller.rb

Overview

Requests to the Resolve controller are OpenURLs. There is one exception: Instead of an OpenURL, you can include the parameter umlaut.request_id=[some id] to hook up to a pre-existing umlaut request (that presumably was an OpenURL).

Constant Summary collapse

@@no_create_request_actions =

Init processing will look at this list, and for actions mentioned, will not create a @user_request if an existing one can’t be found. Used for actions meant only to deal with existing requests.

['background_update']

Instance Method Summary collapse

Methods included from UmlautConfigurable

set_default_configuration!

Instance Method Details

#apiObject



123
124
125
126
127
128
129
130
131
# File 'app/controllers/resolve_controller.rb', line 123

def api

  # Run the request if neccesary. 
  self.service_dispatch()
  @user_request.save!

  api_render()
  
end

#background_statusObject

Display a non-javascript background service status page–or redirect back to index if we’re done.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'app/controllers/resolve_controller.rb', line 70

def background_status

  unless ( @user_request.any_services_in_progress? )
    
    # Just redirect to ordinary index, no need to show progress status.
    # Include request.id, but also context object kev. 
    
    params_hash = 
       {:controller=>"resolve",
        :action=>'index', 
        'umlaut.skip_resolve_menu'.to_sym => params['umlaut.skip_resolve_menu'],
        'umlaut.request_id'.to_sym => @user_request.id }
    
    url = url_for_with_co( params_hash, @user_request.to_context_object )
    
    redirect_to( url )
  else
    # If we fall through, we'll show the background_status view, a non-js
    # meta-refresh update on progress of background services.
    # Your layout should respect this instance var--it will if it uses
    # the resolve_head_content partial, which it should.
    @meta_refresh_self = umlaut_config.lookup!("poll_wait_seconds", 4)
  end
end

#display_coinsObject

Useful for developers, generate a coins. Start from search/journals?umlaut.display_coins=true or search/books?umlaut.display_coins=true



64
65
66
# File 'app/controllers/resolve_controller.rb', line 64

def display_coins

end

#indexObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/controllers/resolve_controller.rb', line 22

def index
  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",
                 :id => link.id )            
  else
    # Render configed view, if configed, or default view if not.             
    render umlaut_config.resolve_view
  end

end

#partial_html_sectionsObject

This action is for external callers. An external caller could get data as xml or json or whatever. But Umlaut already knows how to render it. What if the external caller wants the rendered content, but in discrete letter packets, a packet of HTML for each ServiceTypeValue? This does that, and also let’s the caller know if background services are still running and should be refreshed, and gives the caller a URL to refresh from if neccesary.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'app/controllers/resolve_controller.rb', line 103

def partial_html_sections
  # Tell our application_helper#url_for to generate urls with hostname
  @generate_urls_with_host = true

  # Force background status to be the spinner--default js way of putting
  # spinner in does not generally work through ajax techniques.
  @force_bg_progress_spinner = true

  # Mark that we're doing a partial generation, because it might
  # matter later. 
  @generating_embed_partials = true
      
  # Run the request if neccesary. 
  self.service_dispatch()
  @user_request.save!

  self.api_render()
  
end

#register_requestObject

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.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/resolve_controller.rb', line 45

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

#rescue_action_in_public(exception) ⇒ Object



135
136
137
# File 'app/controllers/resolve_controller.rb', line 135

def rescue_action_in_public(exception)  
  render(:template => "error/resolve_error", :status => 500 ) 
end