diff options
author | Christoph Helma <helma@in-silico.ch> | 2010-08-20 10:31:44 +0200 |
---|---|---|
committer | Christoph Helma <helma@in-silico.ch> | 2010-08-20 10:31:44 +0200 |
commit | 8ed74d040542c8fbd13322eb710ad0c1f06d05c3 (patch) | |
tree | 09386f095e2736c57a6f4c3a07540d693870551f | |
parent | fafa2ba4ad3ae8fc9cd4b85a7094eec38886fbb8 (diff) | |
parent | 4911d9a1fc677dc70287b11ba1f26b425ddc3b09 (diff) |
Merge commit 'mguetlein/test' into development
-rw-r--r-- | application.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/application.rb b/application.rb index f5661b3..a88036c 100644 --- a/application.rb +++ b/application.rb @@ -32,9 +32,9 @@ get '/:id/?' do task = Task.get(params[:id]) halt 404, "Task '#{params[:id]}' not found." unless task - task_content = {:creator => task.creator, :title => task.title, :date => task.created_at.to_s, :hasStatus => task.hasStatus, + task_content = {:creator => task.creator, :title => task.title, :date => task.created_at, :hasStatus => task.hasStatus, :resultURI => task.resultURI, :percentageCompleted => task.percentageCompleted, :description => task.description, - :due_to_time => task.due_to_time.to_s} + :due_to_time => task.due_to_time } code = task.hasStatus == "Running" ? 202 : 200 @@ -48,6 +48,9 @@ get '/:id/?' do owl = OpenTox::Owl.create 'Task', task.uri task_content.each{ |k,v| owl.set(k.to_s,v)} halt code, owl.rdf + when /text\/uri\-list/ + response['Content-Type'] = 'text/uri-list' + halt code, task.resultURI else halt 400, "MIME type '"+request.env['HTTP_ACCEPT'].to_s+"' not supported, valid Accept-Headers are \"application/rdf+xml\" and \"application/x-yaml\"." end @@ -62,14 +65,15 @@ get '/:id/:property/?' do end post '/?' do - LOGGER.debug "Creating new task ..." - task = Task.new - task.save # needed to create id - task.uri = url_for("/#{task.id}", :full) - task.due_to_time = DateTime.parse((Time.parse(task.created_at.to_s) + params[:max_duration].to_f).to_s) if params[:max_duration] - raise "could not save" unless task.save - response['Content-Type'] = 'text/uri-list' - task.uri + "\n" + LOGGER.debug "Creating new task with params "+params.inspect + max_duration = params.delete(:max_duration.to_s) if params.has_key?(:max_duration.to_s) + task = Task.new(params) + task.save # needed to create id + task.uri = url_for("/#{task.id}", :full) + task.due_to_time = DateTime.parse((Time.parse(task.created_at.to_s) + max_duration.to_f).to_s) if max_duration + raise "could not save" unless task.save + response['Content-Type'] = 'text/uri-list' + task.uri + "\n" end put '/:id/:hasStatus/?' do |