aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src
diff options
context:
space:
mode:
authorGeorge Shakhnazaryan <george@shakhnazaryan.com>2011-07-30 13:20:22 -0500
committerGeorge Shakhnazaryan <george@shakhnazaryan.com>2011-07-30 13:20:22 -0500
commit7edcb366e27ba6f04eb9b4ccc5ff460659e19ad7 (patch)
treeeee79f61174d394f43cb254198e657b4244e1a82 /sonar-server/src
parent9b0345b0340b4a55c54c4104c988f8935755e5bf (diff)
downloadsonarqube-7edcb366e27ba6f04eb9b4ccc5ff460659e19ad7.tar.gz
sonarqube-7edcb366e27ba6f04eb9b4ccc5ff460659e19ad7.zip
Add API method to delete project.
Diffstat (limited to 'sonar-server/src')
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb19
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/config/routes.rb1
2 files changed, 19 insertions, 1 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb
index ad53b529d7f..34b0253a90b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/projects_controller.rb
@@ -18,6 +18,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
#
class Api::ProjectsController < Api::ApiController
+
+ before_filter :admin_required, :only => [ :destroy ]
# PARAMETERS
# subprojects [true|false] : load sub-projects ? Default is false. Ignored if the parameter key is set.
@@ -49,7 +51,22 @@ class Api::ProjectsController < Api::ApiController
end
end
-
+ #
+ # DELETE /api/projects/<key>
+ # curl -X DELETE http://localhost:9000/api/projects/<key> -v -u admin:admin
+ #
+ def destroy
+ begin
+ if params[:id]
+ @project = Project.by_key(params[:id])
+ Project.delete_project(@project)
+ end
+ render_success("Project deleted")
+ rescue Exception => e
+ logger.error("Fails to execute #{request.url} : #{e.message}")
+ render_error(e.message)
+ end
+ end
private
diff --git a/sonar-server/src/main/webapp/WEB-INF/config/routes.rb b/sonar-server/src/main/webapp/WEB-INF/config/routes.rb
index ba3c53ba26b..02d72fb7868 100644
--- a/sonar-server/src/main/webapp/WEB-INF/config/routes.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/config/routes.rb
@@ -10,6 +10,7 @@ ActionController::Routing::Routes.draw do |map|
map.namespace :api do |api|
api.resources :events, :only => [:index, :show, :create, :destroy]
api.resources :user_properties, :only => [:index, :show, :create, :destroy], :requirements => { :id => /.*/ }
+ api.resources :projects, :only => [:index, :destroy], :requirements => { :id => /.*/ }
api.resources :favorites, :only => [:index, :show, :create, :destroy], :requirements => { :id => /.*/ }
api.resources :reviews, :only => [:index, :show, :create], :member => {
:add_comment => :put,