class TaskJuggler::ReportServlet

Public Class Methods

get_instance(config, options) click to toggle source
# File lib/taskjuggler/daemon/ReportServlet.rb, line 33
def self.get_instance(config, options)
  self.new(config, options)
end
new(config, options) click to toggle source
Calls superclass method
# File lib/taskjuggler/daemon/ReportServlet.rb, line 25
def initialize(config, options)
  super
  @authKey = options[0]
  @host = options[1]
  @port = options[2]
  @uri = options[3]
end

Public Instance Methods

do_GET(req, res) click to toggle source
# File lib/taskjuggler/daemon/ReportServlet.rb, line 37
def do_GET(req, res)
  debug('', "Serving URL #{req}")
  @req = req
  @res = res
  begin
    # WEBrick is returning the query elements as FormData objects. We must
    # use to_s to explicitely convert them to String objects.
    projectId = req.query['project'].to_s
    debug('', "Project ID: #{projectId}")
    reportId = req.query['report'].to_s
    debug('', "Report ID: #{reportId}")
    if projectId.empty? || reportId.empty?
      debug('', "Project welcome page requested")
      generateWelcomePage(projectId)
    else
      debug('', "Report #{reportId} of project #{projectId} requested")
      attributes = req.query['attributes'] || ''
      unless attributes.empty?
        attributes = URLParameter.decode(attributes)
      end
      debug('', "Attributes: #{attributes}")
      generateReport(projectId, reportId, attributes)
    end
  rescue
    error('get_req_failed', "Cannot serve GET request: #{req}\n#{$!}")
  end
end