diff options
-rw-r--r-- | application.rb | 7 | ||||
-rwxr-xr-x | lazar.rb | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/application.rb b/application.rb index ad13b0d..ec44402 100644 --- a/application.rb +++ b/application.rb @@ -11,6 +11,13 @@ class Model property :yaml, Text, :length => 2**32-1 property :token_id, String, :length => 255 property :created_at, DateTime + + after :save, :check_policy + + def check_policy + OpenTox::Authorization.check_policy(uri, token_id) + end + end DataMapper.auto_upgrade! @@ -292,6 +292,9 @@ 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.save model.uri = url_for("/#{model.id}", :full) model.yaml = request.env["rack.input"].read @@ -307,6 +310,7 @@ post '/:id/?' do # create prediction @prediction = OpenTox::Dataset.new @prediction.creator = lazar.uri + @prediction.token_id = params[:token_id] dependent_variable = YAML.load(lazar.yaml).dependentVariables @prediction.title = URI.decode(dependent_variable.split(/#/).last) case dependent_variable |