--- /dev/null
+#
+# 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/<id>
+ 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/<id>
+ 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
end
end
- # Detail of an issue filter
- # GET /api/filter/<id>
- 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)