summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2011-01-25 16:31:32 +0100
committermguetlein <martin.guetlein@gmail.com>2011-01-25 16:31:32 +0100
commit86ef144e4e16d108c0aafaf1c672e82233e98cdf (patch)
treee9ed8a6c7237a5dda6b41495afb06537cddbaa93
parentd1959af43dd60b6b107c30eaf2aeee72455ffa67 (diff)
parentfe6be7ddb591cee17f3e10a9ccb962cfb34e3fb9 (diff)
Merge remote branch 'rautenberg-dataset/development' into development
-rw-r--r--application.rb14
1 files changed, 6 insertions, 8 deletions
diff --git a/application.rb b/application.rb
index 57e064f..61889c1 100644
--- a/application.rb
+++ b/application.rb
@@ -19,7 +19,7 @@ class Dataset
data = request.env["rack.input"].read
content_type = request.content_type
content_type = "application/rdf+xml" if content_type.nil?
- dataset = OpenTox::Dataset.new
+ dataset = OpenTox::Dataset.new(nil, params[:subjectid])
case content_type
@@ -111,6 +111,7 @@ end
# @return [text/uri-list] List of available datasets
get '/?' do
response['Content-Type'] = 'text/uri-list'
+ params.delete_if{|k,v| k=="subjectid"}
Dataset.all(params).collect{|d| d.uri}.join("\n") + "\n"
end
@@ -138,7 +139,7 @@ get '/:id' do
end
end
- dataset = OpenTox::Dataset.new
+ dataset = OpenTox::Dataset.new(nil, @subjectid)
dataset.load_yaml(Dataset.get(params[:id]).yaml)
halt 404, "Dataset #{params[:id]} empty." if dataset.nil? # not sure how an empty dataset can be returned, but if this happens stale processes keep runing at 100% cpu
@@ -263,8 +264,7 @@ post '/?' do
@dataset = Dataset.create
response['Content-Type'] = 'text/uri-list'
- @dataset.subjectid = params[:subjectid] if params[:subjectid]
- @dataset.subjectid = request.env['HTTP_SUBJECTID'] if !@dataset.subjectid and request.env['HTTP_SUBJECTID']
+ @dataset.subjectid = @subjectid
@dataset.update(:uri => url_for("/#{@dataset.id}", :full))
token_present = params.member?("subjectid") ? 1 : 0
@@ -314,11 +314,9 @@ delete '/:id' do
uri = dataset.uri
FileUtils.rm Dir["public/#{params[:id]}.*"]
dataset.destroy!
- subjectid = params[:subjectid] if params[:subjectid]
- subjectid = request.env['HTTP_SUBJECTID'] if !subjectid and request.env['HTTP_SUBJECTID']
- if subjectid and !Dataset.get(params[:id]) and uri
+ if @subjectid and !Dataset.get(params[:id]) and uri
begin
- res = OpenTox::Authorization.delete_policies_from_uri(uri, subjectid)
+ res = OpenTox::Authorization.delete_policies_from_uri(uri, @subjectid)
LOGGER.debug "Policy deleted for Dataset URI: #{uri} with result: #{res}"
rescue
LOGGER.warn "Policy delete error for Dataset URI: #{uri}"