summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2012-02-20 16:16:56 +0000
committerChristoph Helma <helma@in-silico.ch>2012-02-20 16:16:56 +0000
commitb6134b992fde8784c3556fbca32925e721700d32 (patch)
treefcbac8c01883209aa451282f37592ce4f5794038 /lib
parent64135ae320998a836725786f95a4efd3b63f585c (diff)
task catches and reports errors (some dataset tests still fail)
Diffstat (limited to 'lib')
-rw-r--r--lib/error.rb9
-rw-r--r--lib/opentox-client.rb5
-rw-r--r--lib/opentox.rb13
-rw-r--r--lib/otlogger.rb (renamed from lib/logger.rb)1
-rw-r--r--lib/task.rb2
5 files changed, 19 insertions, 11 deletions
diff --git a/lib/error.rb b/lib/error.rb
index 64cc4eb..6987f35 100644
--- a/lib/error.rb
+++ b/lib/error.rb
@@ -17,16 +17,22 @@ module OpenTox
class NotFoundError < RuntimeError
def http_code; 404; end
end
+
+ class LockedError < RuntimeError
+ def http_code; 423; end
+ end
class ServiceUnavailableError < RuntimeError
def http_code; 503; end
end
+ # TODO: add to RestClientCalls
class RestCallError < RuntimeError
attr_accessor :rest_params
def http_code; 502; end
end
+ # TODO: add to Exception class??
class ErrorReport
# TODO replace params with URIs (errorCause -> OT.errorCause)
@@ -78,11 +84,14 @@ module OpenTox
c
end
+ # TODO: use rdf.rb
def to_rdfxml
s = Serializer::Owl.new
s.add_resource(CONFIG[:services]["opentox-task"]+"/tmpId/ErrorReport/tmpId", OT.errorReport, rdf_content)
s.to_rdfxml
end
+=begin
+=end
end
end
diff --git a/lib/opentox-client.rb b/lib/opentox-client.rb
index c5c701b..fc6cbd1 100644
--- a/lib/opentox-client.rb
+++ b/lib/opentox-client.rb
@@ -5,9 +5,10 @@ require 'rdf/raptor'
require "rest-client"
require 'uri'
require 'yaml'
+require 'logger'
require File.join(File.dirname(__FILE__),"error.rb")
-require File.join(File.dirname(__FILE__),"logger.rb")
+require File.join(File.dirname(__FILE__),"otlogger.rb") # avoid require conflicts with logger
require File.join(File.dirname(__FILE__),"opentox.rb")
require File.join(File.dirname(__FILE__),"task.rb")
require File.join(File.dirname(__FILE__),"compound.rb")
-require File.join(File.dirname(__FILE__),"dataset.rb")
+#require File.join(File.dirname(__FILE__),"dataset.rb")
diff --git a/lib/opentox.rb b/lib/opentox.rb
index ab5c95f..01de3e7 100644
--- a/lib/opentox.rb
+++ b/lib/opentox.rb
@@ -13,7 +13,8 @@ class String
def to_object
# TODO: fix, this is unsafe
self =~ /dataset/ ? uri = File.join(self.chomp,"metadata") : uri = self.chomp
- raise "#{uri} is not a valid URI." unless RDF::URI.new(uri).uri?
+ #raise "#{uri} is not a valid URI." unless RDF::URI.new(uri).uri?
+ raise "#{uri} is not a valid URI." unless uri.uri?
RDF::Reader.open(uri) do |reader|
reader.each_statement do |statement|
if statement.predicate == RDF.type and statement.subject == uri
@@ -82,7 +83,10 @@ module OpenTox
if reload
@metadata = {}
begin
- RDF::Reader.open(@uri) do |reader|
+ #puts self.class
+ #self.kind_of?(OpenTox::Dataset) ? uri = URI.join(@uri,"metadata") : uri = @uri
+ #$logger.debug uri
+ RDF::Reader.open(uri) do |reader|
reader.each_statement do |statement|
@metadata[statement.predicate] = statement.object if statement.subject == @uri
end
@@ -151,9 +155,6 @@ module OpenTox
end
- class FromUri
- end
-
# create default classes
SERVICES.each do |s|
eval "class #{s}
@@ -162,7 +163,5 @@ module OpenTox
end"
end
- private
-
end
diff --git a/lib/logger.rb b/lib/otlogger.rb
index c98f1ca..295d0c1 100644
--- a/lib/logger.rb
+++ b/lib/otlogger.rb
@@ -1,4 +1,3 @@
-require 'logger'
class OTLogger < Logger
def pwd
diff --git a/lib/task.rb b/lib/task.rb
index 52d4a30..582f592 100644
--- a/lib/task.rb
+++ b/lib/task.rb
@@ -89,7 +89,7 @@ module OpenTox
end
rescue
$logger.error "Unknown #{self.class} method #{method}"
- super
+ #super
end
end