From 40b4b943bbaeef4513052f729c32bba7c950e283 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 27 Nov 2009 18:17:21 +0100 Subject: deletion of all datasets enabled --- application.rb | 20 ++++++++++++++++++++ config.ru | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/application.rb b/application.rb index f360432..10b95cf 100644 --- a/application.rb +++ b/application.rb @@ -14,6 +14,19 @@ get '/:id/?' do send_file File.join("datasets",params[:id] + ".rdf") end +get '/:id/features/?' do + + storage = Redland::MemoryStore.new + parser = Redland::Parser.new + data = Redland::Model.new storage + rdf = File.read File.join(File.dirname(__FILE__),"datasets","#{params[:id]}.rdf") + parser.parse_string_into_model(data,rdf,Redland::Uri.new('/')) + + features = [] + data.triples { |s,p,o| features << p.uri.to_s } + features.uniq.join("\n") +end + post '/?' do case request.content_type when"application/rdf+xml" @@ -54,3 +67,10 @@ delete '/:id/?' do "Dataset #{params[:id]} does not exist." end end + +delete '/?' do + Dir["datasets/*rdf"].each do |f| + File.delete f + end + "All datasets deleted." +end diff --git a/config.ru b/config.ru index c3e280a..a7d4daf 100644 --- a/config.ru +++ b/config.ru @@ -7,7 +7,7 @@ require 'rack/contrib' FileUtils.mkdir_p 'log' unless File.exists?('log') FileUtils.mkdir_p 'datasets' unless File.exists?('datasets') log = File.new("log/#{ENV["RACK_ENV"]}.log", "a") -$stdout.reopen(log) +#$stdout.reopen(log) $stderr.reopen(log) if ENV['RACK_ENV'] == 'production' -- cgit v1.2.3