From 970c8beeaa952289ef0d26eb05b43e46f21c9bf3 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Wed, 15 Jan 2014 23:32:56 +0100 Subject: [PATCH] Move web services to get metadata on issue filters to * /api/issue_filters/show/ * /api/issue_filters/favorites --- .../api/issue_filters_controller.rb | 71 +++++++++++++++++++ .../app/controllers/api/issues_controller.rb | 48 ------------- 2 files changed, 71 insertions(+), 48 deletions(-) create mode 100644 sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issue_filters_controller.rb diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issue_filters_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issue_filters_controller.rb new file mode 100644 index 00000000000..eadddbc1566 --- /dev/null +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issue_filters_controller.rb @@ -0,0 +1,71 @@ +# +# SonarQube, open source software quality management tool. +# Copyright (C) 2008-2013 SonarSource +# mailto:contact AT sonarsource DOT com +# +# SonarQube is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 3 of the License, or (at your option) any later version. +# +# SonarQube is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# since 3.6 +class Api::IssueFiltersController < Api::ApiController + + # Detail of an issue filter + # GET /api/issue_filters/show/ + def show + require_parameters :id + filter = Internal.issues.findIssueFilter(params[:id].to_i) + + hash = { + :filter => { + :id => filter.id().to_i, + :name => filter.name(), + :user => filter.user(), + :shared => filter.shared(), + :description => filter.description(), + :query => filter.data() + } + } + + respond_to do |format| + format.json { render :json => jsonp(hash), :status => 200 } + end + end + + # GET /api/issue_filters/favorites/ + def favorites + if logged_in? + favorite_filters = Internal.issues.findFavouriteIssueFiltersForCurrentUser() + else + favorite_filters = [] + end + + hash = { + :favoriteFilters => favorite_filters.map do |filter| + { + :id => filter.id().to_i, + :name => filter.name(), + :user => filter.user(), + :shared => filter.shared(), + :description => filter.description() + # no need to export query field + } + end + } + + respond_to do |format| + format.json { render :json => jsonp(hash), :status => 200 } + end + end +end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb index fb9c564f328..3f5f412f6d4 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb @@ -314,54 +314,6 @@ class Api::IssuesController < Api::ApiController end end - # Detail of an issue filter - # GET /api/filter/ - def filter - require_parameters :id - filter = Internal.issues.findIssueFilter(params[:id].to_i) - - hash = { - :filter => { - :id => filter.id().to_i, - :name => filter.name(), - :user => filter.user(), - :shared => filter.shared(), - :description => filter.description(), - :query => filter.data() - } - } - - respond_to do |format| - format.json { render :json => jsonp(hash), :status => 200 } - end - end - - # GET /api/favorite_filters - def favorite_filters - if logged_in? - favorite_filters = Internal.issues.findFavouriteIssueFiltersForCurrentUser() - else - favorite_filters = [] - end - - hash = { - :favoriteFilters => favorite_filters.map do |filter| - { - :id => filter.id().to_i, - :name => filter.name(), - :user => filter.user(), - :shared => filter.shared(), - :description => filter.description() - # no need to export query field - } - end - } - - respond_to do |format| - format.json { render :json => jsonp(hash), :status => 200 } - end - end - protected def render_result_issue(result) -- 2.39.5