From 612db56ce522a632414158917c2462fe40c242dc Mon Sep 17 00:00:00 2001 From: mguetlein Date: Wed, 4 May 2011 15:27:01 +0200 Subject: use task-status-code from task-service (to fix inconsistent task status codes) --- lib/overwrite.rb | 14 +++++++++----- lib/task.rb | 2 ++ 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/overwrite.rb b/lib/overwrite.rb index fbe775d..fffcb14 100644 --- a/lib/overwrite.rb +++ b/lib/overwrite.rb @@ -39,20 +39,24 @@ end class Sinatra::Base def return_task( task ) - code = task.running? ? 202 : 200 + raise "http_code == nil" unless task.http_code!=nil case request.env['HTTP_ACCEPT'] when /rdf/ response['Content-Type'] = "application/rdf+xml" - halt code,task.to_rdfxml + halt task.http_code,task.to_rdfxml when /yaml/ response['Content-Type'] = "application/x-yaml" - halt code,task.to_yaml # PENDING differs from task-webservice + halt task.http_code,task.to_yaml # PENDING differs from task-webservice when /html/ response['Content-Type'] = "text/html" - halt code,OpenTox.text_to_html(task.to_yaml, @subjectid) + halt task.http_code,OpenTox.text_to_html(task.to_yaml, @subjectid) else # default /uri-list/ response['Content-Type'] = "text/uri-list" - halt code,task.uri+"\n" + if task.completed? + halt task.http_code,task.resultURI+"\n" + else + halt task.http_code,task.uri+"\n" + end end end end diff --git a/lib/task.rb b/lib/task.rb index 0ee3a11..19f42d6 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -8,6 +8,7 @@ module OpenTox def initialize(uri=nil) super uri + @http_code = 202 @metadata = { DC.title => "", DC.date => "", @@ -154,6 +155,7 @@ module OpenTox # not stored just for to_rdf def add_error_report( error_report ) + raise "not an error report: "+error_report.class.to_s unless error_report.is_a?(ErrorReport) @error_report = error_report end -- cgit v1.2.3