summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2011-06-17 00:12:50 +0200
committermguetlein <martin.guetlein@gmail.com>2011-06-17 00:12:50 +0200
commit4c76f80407d61cce9062659a3d041f55980d9cd3 (patch)
tree877577e745b0e670f4c65a24cb2da7526acba80d
parent654ff16ab0c63c9125785e9fe6546973cfe462a7 (diff)
parente06c018afbae2066950bc1cd43262cf7a501ba90 (diff)
Merge branch 'development' of github.com:opentox/validation into development
-rwxr-xr-xexample.rb2
-rwxr-xr-xlib/active_record_setup.rb4
-rwxr-xr-xreach_reports/reach_application.rb10
-rwxr-xr-xreach_reports/reach_persistance.rb1
-rwxr-xr-xreach_reports/reach_service.rb3
-rwxr-xr-xreport/report_application.rb2
-rwxr-xr-xreport/report_persistance.rb2
-rw-r--r--report/statistical_test.rb2
8 files changed, 14 insertions, 12 deletions
diff --git a/example.rb b/example.rb
index b0b591e..636579e 100755
--- a/example.rb
+++ b/example.rb
@@ -80,7 +80,7 @@ class Example
task.progress(10)
log "upload dataset"
- halt 400,"File not found: "+@@file.path.to_s unless File.exist?(@@file.path)
+ raise OpenTox::BadRequestError.new"File not found: "+@@file.path.to_s unless File.exist?(@@file.path)
#data = File.read(@@file.path)
#data_uri = OpenTox::RestClientWrapper.post(CONFIG[:services]["opentox-dataset"],{:content_type => @@file_type},data).chomp("\n")
dataset = OpenTox::Dataset.create_from_csv_file(@@file.path,nil)
diff --git a/lib/active_record_setup.rb b/lib/active_record_setup.rb
index b43e692..5f081af 100755
--- a/lib/active_record_setup.rb
+++ b/lib/active_record_setup.rb
@@ -34,7 +34,7 @@ class ActiveRecord::Base
unless self.column_names.include?(key)
err = "no attribute found: '"+k.to_s+"'"
# if $sinatra
-# $sinatra.halt 400,err
+# $sinatra.raise OpenTox::BadRequestError.newerr
# else
raise err
# end
@@ -47,4 +47,4 @@ class ActiveRecord::Base
#puts "params after "+filter_params.inspect
self.find(:all, :conditions => filter_params)
end
-end \ No newline at end of file
+end
diff --git a/reach_reports/reach_application.rb b/reach_reports/reach_application.rb
index aa64ea2..c0e89b5 100755
--- a/reach_reports/reach_application.rb
+++ b/reach_reports/reach_application.rb
@@ -18,14 +18,14 @@ def mysql_lite_retry( n_times=15 )
end
yield # try a last time
end
-
+
require 'reach_reports/reach_persistance.rb'
require 'reach_reports/reach_service.rb'
require "lib/format_util.rb"
def extract_type(params)
- halt 400, "illegal type, neither QMRF nor QPRF: "+params[:type] unless params[:type] && params[:type] =~ /(?i)Q(M|P)RF/
+ raise OpenTox::BadRequestError.new "illegal type, neither QMRF nor QPRF: "+params[:type] unless params[:type] && params[:type] =~ /(?i)Q(M|P)RF/
params.delete("type")
end
@@ -100,7 +100,7 @@ get '/reach_report/:type/:id' do
case request.env['HTTP_ACCEPT'].to_s
when "application/rdf+xml"
- halt 400, "application/rdf+xml not yet supported"
+ raise OpenTox::BadRequestError.new "application/rdf+xml not yet supported"
owl = OpenTox::Owl.create(type+"Report",rep.report_uri)
owl.set_data( rep.get_content.keys_to_rdf_format )
owl.rdf
@@ -121,7 +121,7 @@ get '/reach_report/:type/:id' do
content_type "application/x-yaml"
rep.to_yaml
else
- halt 400, "MIME type '"+request.env['HTTP_ACCEPT'].to_s+"' not supported, valid Accept-Headers are \"application/rdf+xml\", \"application/x-yaml\", \"application/qmrf-xml\"."
+ raise OpenTox::BadRequestError.new "MIME type '"+request.env['HTTP_ACCEPT'].to_s+"' not supported, valid Accept-Headers are \"application/rdf+xml\", \"application/x-yaml\", \"application/qmrf-xml\"."
end
end
@@ -132,7 +132,7 @@ post '/reach_report/:type/:id' do
rep = ReachReports.get_report(type, params[:id])
input = request.env["rack.input"].read
- halt 400, "no xml data specified" unless input && input.to_s.size>0
+ raise OpenTox::BadRequestError.new "no xml data specified" unless input && input.to_s.size>0
LOGGER.debug "size of posted data: "+input.to_s.size.to_s
ReachReports::QmrfReport.from_xml(rep,input)
diff --git a/reach_reports/reach_persistance.rb b/reach_reports/reach_persistance.rb
index 147ee84..1226d95 100755
--- a/reach_reports/reach_persistance.rb
+++ b/reach_reports/reach_persistance.rb
@@ -1210,6 +1210,7 @@ module ReachReports
model.auto_upgrade!
model.raise_on_save_failure = true
end
+
end
end \ No newline at end of file
diff --git a/reach_reports/reach_service.rb b/reach_reports/reach_service.rb
index 916a7a4..fa4c0d7 100755
--- a/reach_reports/reach_service.rb
+++ b/reach_reports/reach_service.rb
@@ -279,6 +279,7 @@ module ReachReports
end
end
task.progress(90) if task
+
mysql_lite_retry do
r.save
end
@@ -289,7 +290,7 @@ module ReachReports
#
# report_content = get_report(type, id).get_content
# keys.each do |k|
-# $sinatra.halt 400, type+" unknown report property '#{key}'" unless report_content.is_a?(Hash) and report_content.has_key?(k)
+# $sinatra.raise OpenTox::BadRequestError.new type+" unknown report property '#{key}'" unless report_content.is_a?(Hash) and report_content.has_key?(k)
# report_content = report_content[k]
# end
# report_content
diff --git a/report/report_application.rb b/report/report_application.rb
index f7780c3..8f74bd9 100755
--- a/report/report_application.rb
+++ b/report/report_application.rb
@@ -7,7 +7,7 @@ end
def get_docbook_resource(filepath)
perform do |rs|
- halt 404,"not found: "+filepath unless File.exist?(filepath)
+ raise OpenTox::NotFoundError.new"not found: "+filepath unless File.exist?(filepath)
types = MIME::Types.type_for(filepath)
content_type(types[0].content_type) if types and types.size>0 and types[0]
result = body(File.new(filepath))
diff --git a/report/report_persistance.rb b/report/report_persistance.rb
index 78ae47b..e02387f 100755
--- a/report/report_persistance.rb
+++ b/report/report_persistance.rb
@@ -315,7 +315,7 @@ end
# unless prop_names.include?(key)
# err = "no attribute found: '"+k.to_s+"'"
# if $sinatra
-# $sinatra.halt 400,err
+# $sinatra.raise OpenTox::BadRequestError.newerr
# else
# raise err
# end
diff --git a/report/statistical_test.rb b/report/statistical_test.rb
index bee6241..9461cac 100644
--- a/report/statistical_test.rb
+++ b/report/statistical_test.rb
@@ -78,7 +78,7 @@ module Reports
def self.quit_r
LIB::StatisticalTest.quit_r
end
-
+
end
end