From 6edd4387f6e1eaf0178321ca97d9814deb8f3e1f Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 11 Jan 2011 17:01:53 +0100 Subject: get metadata for models / indenting --- application.rb | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'application.rb') diff --git a/application.rb b/application.rb index 99e4619..4fc749d 100644 --- a/application.rb +++ b/application.rb @@ -52,27 +52,30 @@ end get '/?' do # get index of models response['Content-Type'] = 'text/uri-list' + params.delete_if{|k,v| k=="subjectid"} ModelStore.all(params).collect{|m| m.uri}.join("\n") + "\n" 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 -- cgit v1.2.3