]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6617 remove the manual_measures/* RoR WS
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 25 Jun 2015 17:32:31 +0000 (19:32 +0200)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Thu, 25 Jun 2015 17:32:31 +0000 (19:32 +0200)
server/sonar-server/src/main/java/org/sonar/server/measure/ws/ManualMeasuresWs.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel4.java
server/sonar-server/src/test/java/org/sonar/server/measure/ws/ManualMeasuresWsTest.java [deleted file]
server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb [deleted file]

diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ManualMeasuresWs.java b/server/sonar-server/src/main/java/org/sonar/server/measure/ws/ManualMeasuresWs.java
deleted file mode 100644 (file)
index 7a5b3e7..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 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.
- */
-
-package org.sonar.server.measure.ws;
-
-import org.sonar.api.server.ws.RailsHandler;
-import org.sonar.api.server.ws.WebService;
-
-public class ManualMeasuresWs implements WebService {
-
-  @Override
-  public void define(Context context) {
-    NewController controller = context.createController("api/manual_measures");
-    controller.setDescription("Manual measures management");
-    controller.setSince("2.10");
-
-    defineIndexAction(controller);
-
-    controller.done();
-  }
-
-  private static void defineIndexAction(NewController controller) {
-    controller.createAction("index")
-      .setDescription("Documentation of this web service is available <a href=\"http://redirect.sonarsource.com/doc/old-web-service-api.html\">here</a>")
-      .setSince("2.10")
-      .setHandler(RailsHandler.INSTANCE);
-  }
-
-}
index 7a82967845a55bd9075409c911469049bd75ea11..3a5900964b408a97712e0f67e49745a1302196fe 100644 (file)
@@ -166,7 +166,6 @@ import org.sonar.server.measure.MeasureFilterFactory;
 import org.sonar.server.measure.custom.ws.CustomMeasuresWsModule;
 import org.sonar.server.measure.template.MyFavouritesFilter;
 import org.sonar.server.measure.template.ProjectFilter;
-import org.sonar.server.measure.ws.ManualMeasuresWs;
 import org.sonar.server.measure.ws.TimeMachineWs;
 import org.sonar.server.metric.CoreCustomMetrics;
 import org.sonar.server.metric.DefaultMetricFinder;
@@ -489,7 +488,6 @@ public class PlatformLevel4 extends PlatformLevel {
       MeasureFilterFactory.class,
       MeasureFilterExecutor.class,
       MeasureFilterEngine.class,
-      ManualMeasuresWs.class,
       MetricsWsModule.class,
       CustomMeasuresWsModule.class,
       ProjectFilter.class,
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ManualMeasuresWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ManualMeasuresWsTest.java
deleted file mode 100644 (file)
index dae670c..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 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.
- */
-
-package org.sonar.server.measure.ws;
-
-import org.junit.Test;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.server.ws.WsTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class ManualMeasuresWsTest {
-
-  WsTester tester = new WsTester(new ManualMeasuresWs());
-
-  @Test
-  public void define_ws() {
-    WebService.Controller controller = tester.controller("api/manual_measures");
-    assertThat(controller).isNotNull();
-    assertThat(controller.description()).isNotEmpty();
-    assertThat(controller.actions()).hasSize(1);
-  }
-
-}
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/api/manual_measures_controller.rb
deleted file mode 100644 (file)
index e5e90d6..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-#
-# SonarQube, open source software quality management tool.
-# Copyright (C) 2008-2014 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.
-#
-
-require 'json'
-
-class Api::ManualMeasuresController < Api::ApiController
-
-  #
-  # GET /api/manual_measures?resource=<resource>&metric=<optional metric>
-  #
-  def index
-    resource=load_resource(params[:resource], :user)
-
-    metric=nil
-    if params[:metric].present?
-      metric=Metric.by_key(params[:metric])
-      bad_request("Unknown metric: #{params[:metric]}") if metric.nil?
-    end
-
-    result = resource.manual_measures
-    if metric
-      result = result.select{|m| m.metric_id==metric.id}
-    end
-
-    respond_to do |format|
-      format.json { render :json => jsonp(manual_measures_to_json(resource, result)) }
-      format.xml { render :xml => xml_not_supported }
-    end
-  end
-
-    #
-    # POST /api/manual_measures?resource=<resource>&metric=<metric>&val=<optional decimal value>&text=<optional text>
-    # Create or update measure.
-    #
-  def create
-    resource=load_resource(params[:resource], :admin)
-
-    metric=Metric.by_key(params[:metric])
-    bad_request("Unknown metric: #{params[:metric]}") if metric.nil?
-
-    value=params[:val]
-    bad_request("Not a numeric value: #{value}") if value && !Api::Utils.is_number?(value)
-
-    measure=ManualMeasure.first(:conditions => ['resource_id=? and metric_id=?', resource.id, metric.id])
-    if measure.nil?
-      measure=ManualMeasure.new(:resource => resource, :user_login => current_user.login, :metric_id => metric.id)
-    end
-
-    measure.value = value
-    measure.text_value = params[:text]
-    measure.description = params[:desc]
-    measure.save!
-
-    respond_to do |format|
-      format.json { render :json => jsonp(manual_measures_to_json(resource, [measure])) }
-      format.xml { render :xml => xml_not_supported }
-    end
-  end
-  
-
-    #
-    # DELETE /api/manual_measures?resource=<resource>&metric=<metric>
-    #
-  def destroy
-    resource=load_resource(params[:resource], :admin)
-
-    metric=Metric.by_key(params[:metric])
-    bad_request("Unknown metric: #{params[:metric]}") if metric.nil?
-
-    count = ManualMeasure.delete_all(['resource_id=? and metric_id=?', resource.id, metric.id])
-
-    render_success "Deleted #{count} measures"
-  end
-
-  private
-
-  def manual_measures_to_json(resource, manual_measures)
-    json = []
-    manual_measures.each do |m|
-      json<<manual_measure_to_json(resource, m)
-    end
-    json
-  end
-
-  def manual_measure_to_json(resource, manual_measure)
-    hash={:id => manual_measure.id.to_i, :metric => manual_measure.metric.key, :resource => resource.key}
-    hash[:val]=manual_measure.value if manual_measure.value
-    hash[:text]=manual_measure.text_value if manual_measure.text_value
-    hash[:desc]=manual_measure.description if manual_measure.description
-    hash[:created_at]=format_datetime(manual_measure.created_at)
-    hash[:updated_at]=format_datetime(manual_measure.updated_at) if manual_measure.updated_at
-    if manual_measure.user
-      hash[:login]=manual_measure.user_login
-      hash[:username]=manual_measure.user.name
-    end
-    hash
-  end
-end