diff options
author | mguetlein <martin.guetlein@gmail.com> | 2011-01-26 15:58:18 +0100 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2011-01-26 15:58:18 +0100 |
commit | 9750da9cb7dc14309be38f98bc0b50c8bff9eb72 (patch) | |
tree | 8b2ce119a932b6b0b35555eeb551e8ecb6bd35bc /report/report_application.rb | |
parent | 3af7a871c60fb7d853edd348634d6603fccec101 (diff) |
adjust to new A&A for GET, remove old Report-Errorreporting
Diffstat (limited to 'report/report_application.rb')
-rwxr-xr-x | report/report_application.rb | 22 |
1 files changed, 5 insertions, 17 deletions
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)) |