Class: UHFerret::FerretReportServlet

Inherits:
HTTPServlet::AbstractServlet
  • Object
show all
Defined in:
lib/webferret.rb

Overview

This servlet is triggered by a click on 'Download' link in report table It creates the xml report comparing two documents

Instance Method Summary collapse

Instance Method Details

#do_GET(req, res) ⇒ Object

Handles the request to create a report in xml format.



183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/webferret.rb', line 183

def do_GET(req, res)
  upload_dir = req.query["upload"]
  file1 = req.query["file1"].gsub("%20", "\ ")
  file2 = req.query["file2"].gsub("%20", "\ ")
  report_name = "#{upload_dir}/report#{@@next_report}.xml"
  @@next_report += 1
  Dir.chdir "#{upload_dir}"

  `#{FERRET} #{Utils.is_code?(file1) ? "-c" : "-t"} -x "#{report_name}" "#{file1}" "#{file2}"`
  write_style_sheet File.dirname(report_name)
  res["Content-Type"] = "text/html"
  res.body = "<meta HTTP-EQUIV=\"REFRESH\" content=\"0; url=#{report_name}\">"
end