diff options
author | mguetlein <martin.guetlein@gmail.com> | 2011-08-22 11:25:17 +0200 |
---|---|---|
committer | mguetlein <martin.guetlein@gmail.com> | 2011-08-22 11:25:17 +0200 |
commit | 3cdaa1b1f496e1f9511143f6fe83fd2fb42c137f (patch) | |
tree | 8ae451084094c744198819b5d6e8217fb316ac58 | |
parent | b41552185b21f706e7f507020925f3253c38321d (diff) | |
parent | 12b3295738445c941b03b15c34ec9e7f2fb56816 (diff) |
Merge branch 'development' of github.com:opentox/toxcreate into development
-rw-r--r-- | application.rb | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/application.rb b/application.rb index ac19da5..d2ee131 100644 --- a/application.rb +++ b/application.rb @@ -32,7 +32,7 @@ helpers do private def delete_model(model, subjectid=nil) - task = OpenTox::Task.create("Deleting model: #{model.uri}",url_for("/delete",:full)) do |task| + task = OpenTox::Task.create("Deleting model: #{model.web_uri}", url_for("/delete",:full)) do |task| begin OpenTox::RestClientWrapper.put(File.join(model.task_uri, "Cancelled"), "Cancelled",{:subjectid => subjectid}) if model.task_uri rescue LOGGER.warn "Cannot cancel task #{model.task_uri}" end task.progress(15) delete_dependent(model.uri, subjectid) if model.uri @@ -50,15 +50,25 @@ helpers do if model.feature_dataset delete_dependent(model.feature_dataset, subjectid) if model.feature_dataset.match(CONFIG[:services]["opentox-dataset"]) end + task.progress(95) + model.delete + unless ToxCreateModel.get(model.id) + begin + aa = OpenTox::Authorization.delete_policies_from_uri(model.web_uri, @subjectid) + LOGGER.debug "Policy deleted for ToxCreateModel URI: #{model.web_uri} with result: #{aa}" + rescue + LOGGER.warn "Policy delete error for ToxCreateModel URI: #{model.web_uri}" + end + end task.progress(100) - "" + url_for("/models",:full) end end def delete_dependent(uri, subjectid=nil) begin - RestClient.delete(uri, :subjectid => subjectid) if subjectid - RestClient.delete(uri) if !subjectid + OpenTox::RestClientWrapper.delete(uri, :subjectid => subjectid) if subjectid + OpenTox::RestClientWrapper.delete(uri) if !subjectid rescue LOGGER.warn "Can not delete uri: #{uri}" end @@ -452,18 +462,10 @@ delete '/model/:id/?' do model = ToxCreateModel.get(params[:id]) raise OpenTox::NotFoundError.new("Model with id: #{params[:id]} not found!") unless model begin - delete_model(model, @subjectid) - model.delete - unless ToxCreateModel.get(params[:id]) - begin - aa = OpenTox::Authorization.delete_policies_from_uri(model.web_uri, @subjectid) - LOGGER.debug "Policy deleted for Dataset URI: #{uri} with result: #{aa}" - rescue - LOGGER.warn "Policy delete error for Dataset URI: #{uri}" - end - end + delete_model(model, @subjectid) flash[:notice] = "#{model.name} model deleted." rescue + LOGGER.error "#{model.name} model delete error." flash[:notice] = "#{model.name} model delete error." end redirect url_for('/models') |