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



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

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.



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'app/controllers/resolve_controller.rb', line 82

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



77
78
# File 'app/controllers/resolve_controller.rb', line 77

def display_coins
end

Return permalink for request, creating one if it doesn’t already exist. Usually called by AJAX, to create on-demand permalink.



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/resolve_controller.rb', line 38

def get_permalink
  unless current_permalink_url
    permalink = Permalink.new_with_values!(@user_request.referent, @user_request.referrer_id)            
    @user_request.referent.permalinks << permalink
  end

  respond_to do |format|
    format.html 
    format.json do         
      render :json => {:permalink => current_permalink_url}
    end
  end    
end

#indexObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# 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.



110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'app/controllers/resolve_controller.rb', line 110

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.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/controllers/resolve_controller.rb', line 58

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



132
133
134
# File 'app/controllers/resolve_controller.rb', line 132

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