From 6fd9a778573582a414318f20bbe95a7c5606b98d Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Tue, 16 Feb 2010 16:22:46 +0100 Subject: length for uri and file entries extended to 255 characters --- application.rb | 6 +++--- views/compound.xml.builder | 11 ----------- views/dataset.xml.builder | 7 ------- views/feature.xml.builder | 11 ----------- 4 files changed, 3 insertions(+), 32 deletions(-) delete mode 100644 views/compound.xml.builder delete mode 100644 views/dataset.xml.builder delete mode 100644 views/feature.xml.builder diff --git a/application.rb b/application.rb index 8464e89..20f6185 100644 --- a/application.rb +++ b/application.rb @@ -5,8 +5,8 @@ require 'opentox-ruby-api-wrapper' class Dataset include DataMapper::Resource property :id, Serial - property :uri, String, :length => 100 - property :file, String + property :uri, String, :length => 255 + property :file, String, :length => 255 #property :owl, Text, :length => 1000000 property :created_at, DateTime @@ -42,7 +42,7 @@ get '/:id/?' do when /rdf/ # redland sends text/rdf instead of application/rdf+xml dataset.owl when /yaml/ - OpenTox::Dataset.find(uri).to_yaml + OpenTox::Dataset.find(dataset.uri).to_yaml else halt 400, "Unsupported MIME type '#{accept}'" end diff --git a/views/compound.xml.builder b/views/compound.xml.builder deleted file mode 100644 index b4f6cfa..0000000 --- a/views/compound.xml.builder +++ /dev/null @@ -1,11 +0,0 @@ -xml.instruct! -xml.dataset do - @compounds.each do |compound,features| - xml.compound do - xml.uri compound - features.each do |f| - xml.feature_uri f - end - end - end -end diff --git a/views/dataset.xml.builder b/views/dataset.xml.builder deleted file mode 100644 index f540d24..0000000 --- a/views/dataset.xml.builder +++ /dev/null @@ -1,7 +0,0 @@ -xml.instruct! -xml.dataset do - xml.uri url_for("/", :full) + @dataset.id.to_s - xml.name @dataset.name - xml.finished @dataset.finished -end - diff --git a/views/feature.xml.builder b/views/feature.xml.builder deleted file mode 100644 index f9d9881..0000000 --- a/views/feature.xml.builder +++ /dev/null @@ -1,11 +0,0 @@ -xml.instruct! -xml.dataset do - @features.each do |feature,compounds| - xml.feature do - xml.uri feature - compounds.each do |c| - xml.compound_uri c - end - end - end -end -- cgit v1.2.3 From 2dcf602090adbc8df84b9ef473d588b050e8ca0c Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 19 Feb 2010 14:31:40 +0100 Subject: mime types added to response header --- application.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/application.rb b/application.rb index 20f6185..3ec3bba 100644 --- a/application.rb +++ b/application.rb @@ -25,6 +25,7 @@ DataMapper.auto_upgrade! ## REST API get '/?' do + response['Content-Type'] = 'text/uri-list' Dataset.all.collect{|d| d.uri}.join("\n") end @@ -40,8 +41,10 @@ get '/:id/?' do accept = 'application/rdf+xml' if accept == '*/*' or accept == '' or accept.nil? case accept when /rdf/ # redland sends text/rdf instead of application/rdf+xml + response['Content-Type'] = 'application/rdf+xml' dataset.owl when /yaml/ + response['Content-Type'] = 'application/x-yaml' OpenTox::Dataset.find(dataset.uri).to_yaml else halt 400, "Unsupported MIME type '#{accept}'" @@ -92,6 +95,7 @@ post '/?' do end task.pid = pid #status 303 # rest client tries to redirect + response['Content-Type'] = 'text/uri-list' task.uri end @@ -100,6 +104,7 @@ delete '/:id/?' do dataset = Dataset.get(params[:id]) File.delete dataset.file dataset.destroy! + response['Content-Type'] = 'text/plain' "Dataset #{params[:id]} deleted." rescue halt 404, "Dataset #{params[:id]} does not exist." @@ -113,7 +118,9 @@ delete '/?' do rescue LOGGER.error "Cannot delete dataset file '#{d.file}'" end - d.destroy! + #d.destroy! end + Dataset.auto_migrate! + response['Content-Type'] = 'text/plain' "All datasets deleted." end -- cgit v1.2.3