From 9750da9cb7dc14309be38f98bc0b50c8bff9eb72 Mon Sep 17 00:00:00 2001 From: mguetlein Date: Wed, 26 Jan 2011 15:58:18 +0100 Subject: adjust to new A&A for GET, remove old Report-Errorreporting --- report/report_application.rb | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) (limited to 'report/report_application.rb') diff --git a/report/report_application.rb b/report/report_application.rb index b02b780..9fcf871 100755 --- a/report/report_application.rb +++ b/report/report_application.rb @@ -1,20 +1,8 @@ require "report/environment.rb" def perform - begin - @@report_service = Reports::ReportService.instance( url_for("/report", :full) ) unless defined?@@report_service - yield( @@report_service ) - rescue Reports::NotFound => ex - halt 404, ex.message - rescue Reports::BadRequest => ex - halt 400, ex.message - rescue Exception => ex - #LOGGER.error(ex.message) - LOGGER.error "report error: "+ex.message - LOGGER.error ": "+ex.backtrace.join("\n") - raise ex # sinatra returns 501 - #halt 500, ex.message - end + @@report_service = Reports::ReportService.instance( url_for("/report", :full) ) unless defined?@@report_service + yield( @@report_service ) end def get_docbook_resource(filepath) @@ -104,11 +92,11 @@ get '/report/:type/:id' do end end -get '/report/:type/:id/:resource' do - #hack: using request.env['REQUEST_URI'].split("/")[-1] instead of params[:resource] because the file extension is lost +OpenTox::Authorization.whitelist( Regexp.new("/report/.*/[0-9]+/.*"),"GET") +get '/report/:type/:id/:resource' do perform do |rs| - filepath = rs.get_report_resource(params[:type],params[:id],request.env['REQUEST_URI'].split("/")[-1]) + filepath = rs.get_report_resource(params[:type],params[:id],params[:resource]) types = MIME::Types.type_for(filepath) content_type(types[0].content_type) if types and types.size>0 and types[0] result = body(File.new(filepath)) -- cgit v1.2.3