Class: WmsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- WmsController
- Defined in:
- app/controllers/wms_controller.rb
Instance Method Summary collapse
-
#access ⇒ Object
Return 200 for direct accessible WMS and 404 for protected WMS.
- #mapserv ⇒ Object
- #show ⇒ Object
Instance Method Details
#access ⇒ Object
Return 200 for direct accessible WMS and 404 for protected WMS
39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/wms_controller.rb', line 39 def access accessible = public?(params[:service], host_zone(request.host)) expires_in 2.minutes, :public => true if !accessible render :nothing => true, :status => 404 else render :nothing => true end end |
#mapserv ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'app/controllers/wms_controller.rb', line 49 def mapserv require 'lib/mapserver' @@wms = nil if Rails.env.development? path = File.(File.join(Rails.root, 'mapserver', 'maps', @zone)) @@wms ||= Mapserver.new(nil, File.join(path, "#{params[:service]}.map")) status, type, body = @@wms.call(request.env) send_data body, :type => type['Content-Type'], :status => status, :disposition => 'inline' end |
#show ⇒ Object
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 |
# File 'app/controllers/wms_controller.rb', line 6 def show logger.debug "----> WMS call with user '#{current_user.try(:login)}'" topic = Topic.where(:name => params[:service]).first add_sld_body(topic) #Send redirect for public services if public?(params[:service], host_zone(request.host)) url, path = mapserv_request_url(request) #expires_in 2.minutes, :public => true #FIXME: cache_path "wms-public-#{params[:service]}-#{host_zone(request.host)}" redirect_to "#{url.scheme}://#{url.host}#{path}" return end topic_accessible = topic && can?(:show, topic) wms_accessible = can?(:show, Wms.new(params[:service])) if topic_accessible && !wms_accessible topic_accessible = session_ok? if !topic_accessible logger.info "----> WMS '#{params[:service]}' not accessible without valid session!" end end if !topic_accessible && !wms_accessible && !print_request? # allow all topics for print servlet logger.info "----> Topic/WMS '#{params[:service]}' not accessible with roles #{current_roles.roles.collect(&:name).join('+')}!" (:show, topic) if topic (:show, Wms.new(params[:service])) request_http_basic_authentication('Secure WMS Login') return end call_wms(request) end |