diff options
author | mr <mr@mrautenberg.de> | 2010-12-15 11:18:37 +0100 |
---|---|---|
committer | mr <mr@mrautenberg.de> | 2010-12-15 11:18:37 +0100 |
commit | 0499d38412d15a3524b27afb5cb61ab01e42f617 (patch) | |
tree | 9c23e5f3ff3f685c7948dcb94a0a59dc23f323c3 | |
parent | 96356b0d439342b9132847b9f6c38cb7a10206c8 (diff) |
get subjectid also out of request headers for delete
-rw-r--r-- | application.rb | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/application.rb b/application.rb index 99e4619..a2fbd37 100644 --- a/application.rb +++ b/application.rb @@ -56,23 +56,25 @@ get '/?' do # get index of models end delete '/:id/?' do - begin - uri = ModelStore.get(params[:id]).uri - ModelStore.get(params[:id]).destroy! - "Model #{params[:id]} deleted." - if params[:subjectid] and !ModelStore.get(params[:id]) and uri + begin + uri = ModelStore.get(params[:id]).uri + ModelStore.get(params[:id]).destroy! + "Model #{params[:id]} deleted." + subjectid = params[:subjectid] if params[:subjectid] + subjectid = request.env['HTTP_SUBJECTID'] if !subjectid and request.env['HTTP_SUBJECTID'] + if subjectid and !ModelStore.get(params[:id]) and uri begin - aa = OpenTox::Authorization.delete_policies_from_uri(uri, params[:subjectid]) - LOGGER.debug "Policy deleted for Model URI: #{uri} with subjectid: #{params[:subjectid]} with result: #{aa}" + res = OpenTox::Authorization.delete_policies_from_uri(uri, subjectid) + LOGGER.debug "Policy deleted for Model URI: #{uri} with subjectid: #{subjectid} with result: #{res}" rescue LOGGER.warn "Policy delete error for Model URI: #{uri}" end end response['Content-Type'] = 'text/plain' "Model #{params[:id]} deleted." - rescue - halt 404, "Model #{params[:id]} does not exist." - end + rescue + halt 404, "Model #{params[:id]} does not exist." + end end |