From 66dae77b92308bb09781948ad4caf90b770d1ef8 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 13 Jul 2012 12:24:37 +0200 Subject: wait for tasks in post/put requests --- lib/opentox.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/opentox.rb') diff --git a/lib/opentox.rb b/lib/opentox.rb index 9225bb0..019699b 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -67,20 +67,22 @@ module OpenTox end # Post object to webservice - def post service_uri - RestClientWrapper.post service_uri, to_ntriples, { :content_type => "text/plain", :subjectid => @subjectid} + def post service_uri, wait=true + uri = RestClientWrapper.post service_uri, to_ntriples, { :content_type => "text/plain", :subjectid => @subjectid} + OpenTox::Task.new(uri).wait if URI.task?(uri) and wait #rescue # fall back to rdfxml #RestClientWrapper.post service_uri, to_rdfxml, { :content_type => "application/rdf+xml", :subjectid => @subjectid} end # Save object at webservice - def put + def put wait=true append RDF::DC.modified, DateTime.now #begin RestClientWrapper.put @uri.to_s, self.to_ntriples, { :content_type => "text/plain", :subjectid => @subjectid} #rescue # fall back to rdfxml #RestClientWrapper.put @uri.to_s, self.to_rdfxml, { :content_type => "application/rdf+xml", :subjectid => @subjectid} #end + OpenTox::Task.new(uri).wait if URI.task?(uri) and wait end # Delete object at webservice -- cgit v1.2.3