diff options
author | davor <vorgrimmlerdavid@gmx.de> | 2012-08-17 17:13:56 +0200 |
---|---|---|
committer | davor <vorgrimmlerdavid@gmx.de> | 2012-08-17 17:13:56 +0200 |
commit | c4c314a99902b68b544aed0cc1ee6a616fbc78db (patch) | |
tree | b3992cf3f0e0e0b48b6e3e478800502487701664 | |
parent | f68801665dd06144c5e16f1d57b330790b3bb70a (diff) | |
parent | 482e408c9f5509a2615a50247a8fe67588127a99 (diff) |
Merge branch 'development' into migration
Conflicts:
lib/opentox.rb
-rw-r--r-- | lib/4store.rb | 16 | ||||
-rw-r--r-- | lib/authorization-helper.rb | 2 | ||||
-rw-r--r-- | lib/opentox.rb | 7 |
3 files changed, 14 insertions, 11 deletions
diff --git a/lib/4store.rb b/lib/4store.rb index f6879b0..8715ea7 100644 --- a/lib/4store.rb +++ b/lib/4store.rb @@ -29,11 +29,11 @@ module OpenTox bad_request_error "'#{mime_type}' is not a supported content type. Please use one of #{@@content_type_formats.join(", ")}." unless @@content_type_formats.include? mime_type or mime_type == "multipart/form-data" bad_request_error "Reqest body empty." unless rdf mime_type = "application/x-turtle" if mime_type == "text/plain" # ntriples is turtle in 4store - #begin + begin RestClient.post File.join(four_store_uri,"data")+"/", :data => rdf, :graph => uri, "mime-type" => mime_type - #rescue - #rest_call_error $!.message, File.join(four_store_uri,"data")+"/" - #end + rescue + bad_request_error $!.message, File.join(four_store_uri,"data")+"/" + end end def self.put uri, rdf, mime_type @@ -41,9 +41,9 @@ module OpenTox bad_request_error "Reqest body empty." unless rdf mime_type = "application/x-turtle" if mime_type == "text/plain" #begin - RestClient.put File.join(four_store_uri,"data",uri), rdf, :content_type => mime_type + RestClientWrapper.put File.join(four_store_uri,"data",uri), rdf, :content_type => mime_type #rescue - #rest_call_error $!.message, File.join(four_store_uri,"data",uri) + #bad_request_error $!.message, File.join(four_store_uri,"data",uri) #end end @@ -91,8 +91,8 @@ module OpenTox # TODO: check if this prevents SPARQL injections bad_request_error "Only SELECT and CONSTRUCT are accepted SPARQL statements." end - #rescue - #rest_call_error $!.message, sparql_uri + rescue + bad_request_error $!.message, sparql_uri end def self.klass diff --git a/lib/authorization-helper.rb b/lib/authorization-helper.rb index b0b5374..5e2f1d5 100644 --- a/lib/authorization-helper.rb +++ b/lib/authorization-helper.rb @@ -56,7 +56,7 @@ module OpenTox elsif !env["session"] && subjectid unless authorized?(subjectid) $logger.debug "URI not authorized: clean: " + clean_uri("#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}#{request.env['REQUEST_URI']}").sub("http://","https://").to_s + " full: #{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}#{request.env['REQUEST_URI']} with request: #{request.env['REQUEST_METHOD']}" - unauthorized_error "Not authorized" + unauthorized_error "Not authorized #{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}#{request.env['REQUEST_URI']} with request: #{request.env['REQUEST_METHOD']}" end else unauthorized_error "Not authorized" unless authorized?(subjectid) diff --git a/lib/opentox.rb b/lib/opentox.rb index ac66b57..87d6186 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -1,8 +1,8 @@ require 'sinatra/base' +require "sinatra/reloader" ENV["RACK_ENV"] ||= "production" -require "sinatra/reloader" if ENV["RACK_ENV"] == "development" require File.join(ENV["HOME"],".opentox","config","default.rb") -require File.join(ENV["HOME"],".opentox","config","#{SERVICE}.rb") if File.exist?(File.join(ENV["HOME"],".opentox","config","#{SERVICE}.rb")) +require File.join(ENV["HOME"],".opentox","config","#{SERVICE}.rb") logfile = File.join(ENV['HOME'], ".opentox","log","#{ENV["RACK_ENV"]}.log") @@ -21,6 +21,9 @@ module OpenTox configure :development do register Sinatra::Reloader + also_reload "./*.rb" + also_reload "../opentox-client/lib/*.rb" + also_reload File.join(ENV["HOME"],".opentox","config","#{SERVICE}.rb") end before do |