summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2010-07-30 16:23:09 +0200
committermr <mr@mrautenberg.de>2010-07-30 16:23:09 +0200
commit3de9e162beeb5f88d68505b560bc4dea7737e5f8 (patch)
tree9dd8519637e750c214f99ff8deb217ee0874ee60
parent91acc6de3edf5c36b2f29c3c5659d4748302457c (diff)
Authorization minor changes => testing
-rw-r--r--application.rb8
-rwxr-xr-xlazar.rb9
2 files changed, 9 insertions, 8 deletions
diff --git a/application.rb b/application.rb
index ec44402..d1ff70e 100644
--- a/application.rb
+++ b/application.rb
@@ -12,8 +12,9 @@ class Model
property :token_id, String, :length => 255
property :created_at, DateTime
- after :save, :check_policy
+ after :save, :check_policy
+ private
def check_policy
OpenTox::Authorization.check_policy(uri, token_id)
end
@@ -50,9 +51,10 @@ delete '/:id/?' do
uri = model.uri
model.destroy!
"Model #{params[:id]} deleted."
- if params["token_id"] and !Model.get(params[:id]) and uri
+ if params[:token_id] and !Model.get(params[:id]) and uri
begin
- aa = OpenTox::Authorization.delete_policy_from_uri(uri, params["token_id"])
+ aa = OpenTox::Authorization.delete_policy_from_uri(uri, params[:token_id])
+ LOGGER.debug "Policy deleted for Model URI: #{uri} with token_id: #{params[:token_id]} with result: #{aa}"
rescue
LOGGER.warn "Policy delete error for Model URI: #{uri}"
end
diff --git a/lazar.rb b/lazar.rb
index 19a4b2a..e43995d 100755
--- a/lazar.rb
+++ b/lazar.rb
@@ -291,11 +291,10 @@ end
post '/?' do # create model
halt 400, "MIME type \"#{request.content_type}\" not supported." unless request.content_type.match(/yaml/)
- model = Lazar.new
- model.token_id = params["token_id"] if params["token_id"]
- LOGGER.debug "mr create model post /model/? with token_id: #{model.token_id}"
- #model.token_id = request.env["HTTP_TOKEN_ID"] if request.env["HTTP_TOKEN_ID"]
+ model = Lazar.new
model.save
+ model.token_id = params[:token_id] if params[:token_id]
+ model.token_id = request.env["HTTP_TOKEN_ID"] if !model.token_id and request.env["HTTP_TOKEN_ID"]
model.uri = url_for("/#{model.id}", :full)
model.yaml = request.env["rack.input"].read
model.save
@@ -311,6 +310,7 @@ post '/:id/?' do # create prediction
@prediction = OpenTox::Dataset.new
@prediction.creator = lazar.uri
@prediction.token_id = params[:token_id]
+ @prediction.token_id = request.env["HTTP_TOKEN_ID"] if !@prediction.token_id and request.env["HTTP_TOKEN_ID"]
dependent_variable = YAML.load(lazar.yaml).dependentVariables
@prediction.title = URI.decode(dependent_variable.split(/#/).last)
case dependent_variable
@@ -357,7 +357,6 @@ post '/:id/?' do # create prediction
end
haml :prediction
end
-
elsif dataset_uri
response['Content-Type'] = 'text/uri-list'
task_uri = OpenTox::Task.as_task do