aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2011-06-10 15:24:57 +0200
committersimonbrandhof <simon.brandhof@gmail.com>2011-06-10 15:24:57 +0200
commit78e9b96a51e2ef677a4eb8b801e18248d7e32283 (patch)
treee0bae2cb0f36df7ac10edddcb929683437abc2c1
parent3203b81516eb93052a05b74c6e0a5ddc7f1977ca (diff)
parent231d8aeceb89848a8099f1d516f85d76106f3fef (diff)
downloadsonarqube-78e9b96a51e2ef677a4eb8b801e18248d7e32283.tar.gz
sonarqube-78e9b96a51e2ef677a4eb8b801e18248d7e32283.zip
Merge remote branch 'upstream/master'
-rw-r--r--plugins/sonar-checkstyle-plugin/pom.xml5
-rw-r--r--plugins/sonar-core-gwt/pom.xml1
-rw-r--r--plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/Clouds.java42
-rw-r--r--plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/Calculator.java119
-rw-r--r--plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/GwtClouds.java197
-rw-r--r--plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/model/CloudElement.java53
-rw-r--r--plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/model/Color.java50
-rw-r--r--plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/widget/ClassCloudsWidget.java146
-rw-r--r--plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/widget/TabWidget.java77
-rw-r--r--plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/GwtClouds.gwt.xml11
-rw-r--r--plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/GwtCloudsDev.gwt.xml6
-rw-r--r--plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/public/clouds.css29
-rw-r--r--plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/public/test.html39
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java2
-rw-r--r--plugins/sonar-squid-java-plugin/pom.xml5
-rw-r--r--pom.xml28
-rw-r--r--quick-build.bat2
-rwxr-xr-xquick-build.sh2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapClassLoader.java53
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java4
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcDriverHolder.java132
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcLeakPrevention.java64
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java4
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/bootstrap/BootstrapClassLoaderTest.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/jpa/session/DriverDatabaseConnector.java70
-rw-r--r--sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java5
-rw-r--r--sonar-plugin-api/pom.xml23
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/AbstractPage.java50
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/ResourceDictionary.java63
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/Utils.java156
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/AbstractResourceQuery.java43
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/BaseQueryCallback.java56
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JSONHandlerDispatcher.java52
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JsonUtils.java186
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java155
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/MetricsQuery.java108
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Query.java29
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/QueryCallBack.java36
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resource.java191
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resources.java67
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java262
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResponsePOJO.java31
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java58
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SequentialQueries.java116
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/VoidResponse.java28
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java247
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/widgets/LoadingLabel.java34
-rw-r--r--sonar-server/src/main/java/org/sonar/server/filters/Filter.java11
-rw-r--r--sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java5
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/cloud_controller.rb72
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/helpers/cloud_helper.rb33
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_change.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/measure_color.rb9
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/models/review.rb4
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb63
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb12
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/config/locales/de.yml10
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/config/locales/en-AU.yml (renamed from sonar-server/src/main/webapp/WEB-INF/config/locales/en.yml)2
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/config/locales/en-GB.yml13
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/config/locales/en-US.yml13
-rw-r--r--sonar-server/src/main/webapp/stylesheets/style.css18
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java4
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java5
65 files changed, 549 insertions, 2871 deletions
diff --git a/plugins/sonar-checkstyle-plugin/pom.xml b/plugins/sonar-checkstyle-plugin/pom.xml
index 7c5109974b2..a8e3ba70b59 100644
--- a/plugins/sonar-checkstyle-plugin/pom.xml
+++ b/plugins/sonar-checkstyle-plugin/pom.xml
@@ -44,6 +44,11 @@
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</exclusion>
+ <exclusion>
+ <!-- See SONAR-2512 -->
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils-core</artifactId>
+ </exclusion>
</exclusions>
</dependency>
diff --git a/plugins/sonar-core-gwt/pom.xml b/plugins/sonar-core-gwt/pom.xml
index 49a33806fe4..b7a23610f9b 100644
--- a/plugins/sonar-core-gwt/pom.xml
+++ b/plugins/sonar-core-gwt/pom.xml
@@ -59,7 +59,6 @@
<execution>
<configuration>
<modules>
- <module>org.sonar.plugins.core.clouds.GwtClouds${gwt.permutationSuffix}</module>
<module>org.sonar.plugins.core.duplicationsviewer.DuplicationsViewer${gwt.permutationSuffix}</module>
<module>org.sonar.plugins.core.testdetailsviewer.TestsViewer${gwt.permutationSuffix}</module>
<module>org.sonar.plugins.core.hotspots.GwtHotspots${gwt.permutationSuffix}</module>
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/Clouds.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/Clouds.java
deleted file mode 100644
index 946fb6a0b63..00000000000
--- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/Clouds.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.clouds;
-
-import org.sonar.api.resources.Resource;
-import org.sonar.api.web.GwtPage;
-import org.sonar.api.web.NavigationSection;
-import org.sonar.api.web.ResourceScope;
-import org.sonar.api.web.UserRole;
-import org.sonar.plugins.core.clouds.client.GwtClouds;
-
-@NavigationSection(NavigationSection.RESOURCE)
-@ResourceScope({Resource.SCOPE_SET, Resource.SCOPE_SPACE})
-@UserRole(UserRole.USER)
-public class Clouds extends GwtPage {
-
- public String getGwtId() {
- return GwtClouds.GWT_ID;
- }
-
- public String getTitle() {
- return "Clouds";
- }
-
-} \ No newline at end of file
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/Calculator.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/Calculator.java
deleted file mode 100644
index c63e667f989..00000000000
--- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/Calculator.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.clouds.client;
-
-import org.sonar.plugins.core.clouds.client.model.Color;
-
-public class Calculator {
-
- private Float minValue;
- private Float maxValue;
- private Float minPercent;
- private Float maxPercent;
-
- public Calculator(Float minPercent, Float maxPercent) {
- this.minPercent = minPercent;
- this.maxPercent = maxPercent;
- }
-
- public void updateMaxAndMin(Float value){
- updateMaxValue(value);
- updateMinValue(value);
- }
-
- public Integer getFontSizePercent(Integer value) {
- float divisor = getMaxValue() - getMinValue();
- float size = getMinPercent();
- if (divisor != 0) {
- float multiplier = (getMaxPercent() - getMinPercent()) / divisor;
- size = getMinPercent() +
- ((getMaxValue() - (getMaxValue() - (value - getMinValue()))) * multiplier);
- }
- return Float.valueOf(size).intValue();
- }
-
- public String getFontColor(float value) {
- float interval = (getMaxPercent() - getMinPercent()) / 2f;
- float mean = (getMinPercent() + getMaxPercent()) / 2f;
-
- Color minColor = new Color(191/255f, 0f, 21/255f); // red
- Color meanColor = new Color(77/255f, 5/255f, 177/255f); // purple
- Color maxColor = new Color(23/255f, 96/255f, 191/255f); // blue
-
- Color color;
- if (value > mean) {
- float valuePercent = ((value - mean) / interval) * 100f;
- color = mixColorWith(maxColor, meanColor, valuePercent);
- } else {
- float valuePercent = ((mean - value) / interval) * 100f;
- color = mixColorWith(minColor, meanColor, valuePercent);
- }
-
- int r = Float.valueOf(color.getRed()* 255f).intValue();
- int g = Float.valueOf(color.getGreen() * 255f).intValue();
- int b = Float.valueOf(color.getBlue() * 255f).intValue();
-
- return ("rgb("+ r +","+ g +","+ b +")");
- }
-
- private Color mixColorWith(Color currentColor, Color mask, float value){
- float opacity = value / 100f;
-
- float r = (currentColor.getRed() * opacity) + (mask.getRed() * (1f - opacity));
- float g = (currentColor.getGreen() * opacity) + (mask.getGreen() * (1f - opacity));
- float b = (currentColor.getBlue() * opacity) + (mask.getBlue() * (1f - opacity));
-
- return new Color(r, g, b);
- }
-
-
- private void updateMaxValue(Float value) {
- if (maxValue == null) {
- maxValue = value;
- } else if (value > maxValue) {
- maxValue = value;
- }
- }
-
- private void updateMinValue(Float value) {
- if (minValue == null) {
- minValue = value;
- } else if (value < minValue) {
- minValue = value;
- }
- }
-
-
- public Float getMinValue() {
- return minValue;
- }
-
- public Float getMaxValue() {
- return maxValue;
- }
-
- public Float getMinPercent() {
- return minPercent;
- }
-
- public Float getMaxPercent() {
- return maxPercent;
- }
-}
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/GwtClouds.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/GwtClouds.java
deleted file mode 100644
index 9b07b53d915..00000000000
--- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/GwtClouds.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.clouds.client;
-
-import com.google.gwt.core.client.JavaScriptException;
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.event.dom.client.ChangeEvent;
-import com.google.gwt.event.dom.client.ChangeHandler;
-import com.google.gwt.event.logical.shared.SelectionEvent;
-import com.google.gwt.event.logical.shared.SelectionHandler;
-import com.google.gwt.user.client.ui.*;
-import org.sonar.api.web.gwt.client.AbstractPage;
-import org.sonar.api.web.gwt.client.ResourceDictionary;
-import org.sonar.api.web.gwt.client.webservices.*;
-import org.sonar.api.web.gwt.client.webservices.WSMetrics.Metric;
-import org.sonar.api.web.gwt.client.webservices.WSMetrics.MetricsList;
-import org.sonar.api.web.gwt.client.widgets.LoadingLabel;
-import org.sonar.plugins.core.clouds.client.widget.ClassCloudsWidget;
-import org.sonar.plugins.core.clouds.client.widget.TabWidget;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class GwtClouds extends AbstractPage {
-
- public static final String GWT_ID = "org.sonar.plugins.core.clouds.GwtClouds";
-
- private Panel cloudsPanel;
- private ListBox metricsListBox;
- private Label sizeAndColorLabel;
- private TabWidget sizeTabs;
- private Resources resources;
-
- private final List<SizeMetric> SIZE_METRICS = Arrays.asList(
- new SizeMetric("Quick Wins", WSMetrics.NCLOC),
- new SizeMetric("Top risk", WSMetrics.FUNCTION_COMPLEXITY));
-
- private final List<Metric> COLOR_METRICS = Arrays.asList(WSMetrics.COVERAGE, WSMetrics.VIOLATIONS_DENSITY);
-
- public void onModuleLoad() {
- cloudsPanel = new FlowPanel();
- displayView(cloudsPanel);
- loadClouds();
- }
-
- protected void loadClouds() {
- String projectKey = ResourceDictionary.getResourceKey();
- final List<Metric> metricsToGet = new ArrayList<Metric>();
- for (SizeMetric size : SIZE_METRICS) {
- metricsToGet.add(size.getSizeMetric());
- }
- for (Metric color : COLOR_METRICS) {
- metricsToGet.add(color);
- }
- if (projectKey != null) {
- cloudsPanel.add(new LoadingLabel());
-
- Query<Resources> resourcesQuery = ResourcesQuery.get(projectKey).setDepth(-1).setScopes(Resource.SCOPE_ENTITY).setMetrics(metricsToGet);
- QueryCallBack<Resources> resourcesCb = new BaseQueryCallback<Resources>() {
- public void onResponse(Resources response, JavaScriptObject jsonRawResponse) {
- resources = response;
- }
- };
- Query<MetricsList> metrics = MetricsQuery.get().setUserManaged(false);
- QueryCallBack<MetricsList> metricsCb = new BaseQueryCallback<MetricsList>() {
- public void onResponse(MetricsList response, JavaScriptObject jsonRawResponse) {
- // nothing to do WSMetrics.getUpdateMetricsFromServer will update the metrics labels
- }
- };
- metricsCb = WSMetrics.getUpdateMetricsFromServer(metricsCb);
-
- QueryCallBack<VoidResponse> updateCloudsCb = new BaseQueryCallback<VoidResponse>() {
- public void onResponse(VoidResponse response, JavaScriptObject jsonRawResponse) {
- updateClouds(resources);
- }
- };
-
- SequentialQueries.get().add(resourcesQuery, resourcesCb).add(metrics, metricsCb).execute(updateCloudsCb);
- }
- }
-
- private void updateClouds(Resources resources) {
- cloudsPanel.clear();
- Panel metricSelectPanel = getMetricColorSelectBox(resources);
- sizeTabs = new TabWidget(new SelectionHandler<Integer>() {
- public void onSelection(SelectionEvent<Integer> event) {
- renderClassCloudsForCurrentMetric();
- }
- });
- for (SizeMetric size : SIZE_METRICS) {
- ClassCloudsWidget classCloudsTab = new ClassCloudsWidget(resources.getResources(), size.getSizeMetric());
- sizeTabs.addTab(classCloudsTab, size.getTabName(), size.getTabNameId());
- }
-
- cloudsPanel.add(metricSelectPanel);
- cloudsPanel.add(sizeTabs);
- }
-
- private Panel getMetricColorSelectBox(Resources resources) {
- HTMLPanel metricSelectPanel = new HTMLPanel("<div id='select_metric' class='metricSelectBox small'> </div>");
- sizeAndColorLabel = new InlineLabel();
- sizeAndColorLabel.setStyleName("labelText gray");
- metricSelectPanel.add(sizeAndColorLabel, "select_metric");
- metricsListBox = new ListBox(false);
- for (Metric color : COLOR_METRICS) {
- if (resources.onceContainsMeasure(color)) {
- metricsListBox.addItem(color.getName(), color.getKey());
- }
- }
- metricSelectPanel.add(metricsListBox, "select_metric");
-
- metricsListBox.addChangeHandler(new ChangeHandler() {
- public void onChange(ChangeEvent event) {
- renderClassCloudsForCurrentMetric();
- }
- });
- return metricSelectPanel;
- }
-
- private void generateSizeAndColorLabel() {
- sizeAndColorLabel.setText("Size : " + getCurrentSizeMetric().getName() + ", color : ");
- }
-
- private void renderClassCloudsForCurrentMetric() {
- Widget widget = sizeTabs.getSelectedWidget();
- if (widget instanceof ClassCloudsWidget) {
- Metric current = getCurrentColorMetric();
- ClassCloudsWidget classCloudsWidget = (ClassCloudsWidget) widget;
- classCloudsWidget.generateCloud(current);
- generateSizeAndColorLabel();
- }
- }
-
- private Metric getCurrentColorMetric() {
- String metricKey = metricsListBox.getValue(metricsListBox.getSelectedIndex());
- for (Metric color : COLOR_METRICS) {
- if (color.getKey().equals(metricKey)) {
- return color;
- }
- }
- throw new JavaScriptException("Unable to find metric " + metricKey);
- }
-
- private Metric getCurrentSizeMetric() {
- String selectedTabId = sizeTabs.getSelectedTabId();
- for (SizeMetric size : SIZE_METRICS) {
- if (size.getTabNameId().equals(selectedTabId)) {
- return size.sizeMetric;
- }
- }
- throw new JavaScriptException("Unable to find metric for tab " + selectedTabId);
- }
-
-
- private class SizeMetric {
-
- private String tabName;
- private Metric sizeMetric;
-
- public SizeMetric(String tabName, Metric sizeMetric) {
- super();
- this.tabName = tabName;
- this.sizeMetric = sizeMetric;
- }
-
- public String getTabName() {
- return tabName;
- }
-
- public Metric getSizeMetric() {
- return sizeMetric;
- }
-
- public String getTabNameId() {
- return tabName.toLowerCase().replace(' ', '_');
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/model/CloudElement.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/model/CloudElement.java
deleted file mode 100644
index 08bcac836b0..00000000000
--- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/model/CloudElement.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.clouds.client.model;
-
-import org.sonar.api.web.gwt.client.webservices.Resource;
-
-
-public class CloudElement implements Comparable<CloudElement> {
-
- private Integer fontSize;
- private Float fontColor;
- private Resource resource;
-
- public CloudElement(Resource resource, Integer fontSize, Float fontColor) {
- this.resource = resource;
- this.fontSize = fontSize;
- this.fontColor = fontColor;
- }
-
- public Resource getResource() {
- return resource;
- }
-
- public Integer getFontSize() {
- return fontSize;
- }
-
- public Float getFontColor() {
- return fontColor;
- }
-
- public int compareTo(CloudElement cloudElement) {
- return resource.getName().compareTo(cloudElement.getResource().getName());
- }
-
-}
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/model/Color.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/model/Color.java
deleted file mode 100644
index d3f8f6f988e..00000000000
--- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/model/Color.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.clouds.client.model;
-
-public class Color {
-
- private float red;
- private float green;
- private float blue;
-
- public Color(float red, float green, float blue) {
- this.red = red;
- this.green = green;
- this.blue = blue;
- }
-
- public float getRed() {
- return red;
- }
-
- public float getGreen() {
- return green;
- }
-
- public float getBlue() {
- return blue;
- }
-
- @Override
- public String toString() {
- return ("red : "+ red + ", green : "+ green + ", blue : "+ blue );
- }
-}
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/widget/ClassCloudsWidget.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/widget/ClassCloudsWidget.java
deleted file mode 100644
index d3233fd8519..00000000000
--- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/widget/ClassCloudsWidget.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.clouds.client.widget;
-
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.Window;
-import com.google.gwt.user.client.ui.*;
-import org.sonar.api.web.gwt.client.Utils;
-import org.sonar.api.web.gwt.client.webservices.Measure;
-import org.sonar.api.web.gwt.client.webservices.Resource;
-import org.sonar.api.web.gwt.client.webservices.WSMetrics.Metric;
-import org.sonar.api.web.gwt.client.widgets.LoadingLabel;
-import org.sonar.plugins.core.clouds.client.Calculator;
-import org.sonar.plugins.core.clouds.client.GwtClouds;
-import org.sonar.plugins.core.clouds.client.model.CloudElement;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class ClassCloudsWidget extends Composite {
-
- private Panel main;
- private Metric sizeMetric;
- private List<Resource> resources;
- private float minSizePercent = 60f;
- private float maxSizePercent = 240f;
-
- private Calculator sizeCalculator = new Calculator(minSizePercent, maxSizePercent);
- private Calculator colorCalculator = new Calculator(0f, 100f);
-
- public ClassCloudsWidget(List<Resource> resources, Metric sizeMetric) {
- this.sizeMetric = sizeMetric;
- this.main = new FlowPanel();
- this.resources = resources;
- initWidget(main);
- }
-
- public Metric getSizeMetric() {
- return sizeMetric;
- }
-
- public void generateCloud(Metric colorMetric) {
- main.clear();
- LoadingLabel loading = new LoadingLabel();
- main.add(loading);
- if (colorMetric.equals(colorMetric)) {
- List<CloudElement> cloudElements = getCloudElements(resources, colorMetric);
- createClouds(cloudElements, colorMetric);
- }
- main.remove(loading);
- }
-
- private List<CloudElement> getCloudElements(List<Resource> resources, Metric colorMetric) {
- List<CloudElement> tagList = new ArrayList<CloudElement>();
- for (Resource resource : resources) {
- Measure sizeMeasure = getMeasure(resource, sizeMetric);
- Measure colorMeasure = getMeasure(resource, colorMetric);
-
- if (sizeMeasure != null && colorMeasure != null) {
- Integer size = getMeasureValue(sizeMeasure.getValue());
- float color = colorMeasure.getValue().floatValue();
- tagList.add(new CloudElement(resource, size, color));
- sizeCalculator.updateMaxAndMin(Float.valueOf(size.toString()));
- }
- }
- Collections.sort(tagList);
- return tagList;
- }
-
- private Integer getMeasureValue(Double value) {
- Float floatValue = (value.floatValue() * 100.0f);
- return floatValue.intValue();
- }
-
- private Measure getMeasure(Resource project, Metric metricToFind) {
- return project.getMeasure(metricToFind);
- }
-
- private void createClouds(List<CloudElement> cloudElements, Metric colorMetric) {
- for (CloudElement tag : cloudElements) {
- HTML className = new HTML(
- "<span style=\"font-size:" + Integer.toString(sizeCalculator.getFontSizePercent(tag.getFontSize())) +
- "%; color:" + colorCalculator.getFontColor(tag.getFontColor()) + "\" >" +
- tag.getResource().getName() + "</span>\n");
- className.setStyleName("inline");
-
- Hyperlink link = createLink(tag, colorMetric);
- link.setHTML(className.getHTML());
- main.add(link);
- }
- }
-
- private Hyperlink createLink(CloudElement tag, final Metric colorMetric) {
- Hyperlink link = new Hyperlink();
- link.setStyleName("tag inline");
- String tooltip = getTooltip(tag.getResource(), colorMetric);
- link.getElement().setAttribute("title", tooltip);
- link.getElement().setAttribute("rel", tooltip);
-
- String sizeCss = Float.toString(maxSizePercent / 100f) + "em";
- link.setHeight(sizeCss);
- final Resource clickResource = tag.getResource();
- link.addClickHandler(new ClickHandler() {
- public void onClick(final ClickEvent event) {
- if (clickResource.getCopy() != null) {
- Window.Location.assign(Utils.getServerUrl() + "/plugins/resource/" + clickResource.getCopy() + "?page=" + GwtClouds.GWT_ID);
- } else {
- Utils.openResourcePopup(clickResource, colorMetric.getKey());
- }
- }
- });
-
- return link;
- }
-
- private String getTooltip(Resource resource, Metric colorMetric) {
- Measure sizeMeasure = getMeasure(resource, sizeMetric);
- String sizeMetricName = sizeMetric.getName();
- String sizeMetricValue = sizeMeasure.getFormattedValue();
-
- Measure colorMeasure = getMeasure(resource, colorMetric);
- String colorMetricName = colorMetric.getName();
- String colorMetricValue = colorMeasure.getFormattedValue();
-
- return resource.getName(true) + ", " + sizeMetricName + " : " + sizeMetricValue + ", " + colorMetricName + " : " + colorMetricValue;
- }
-}
diff --git a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/widget/TabWidget.java b/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/widget/TabWidget.java
deleted file mode 100644
index ace9d651a01..00000000000
--- a/plugins/sonar-core-gwt/src/main/java/org/sonar/plugins/core/clouds/client/widget/TabWidget.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.plugins.core.clouds.client.widget;
-
-import com.google.gwt.event.logical.shared.SelectionEvent;
-import com.google.gwt.event.logical.shared.SelectionHandler;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.Label;
-import com.google.gwt.user.client.ui.TabPanel;
-import com.google.gwt.user.client.ui.Widget;
-
-public class TabWidget extends Composite {
-
- private TabPanel tab = new TabPanel();
-
- private Integer nbTab;
- private final Integer defaultSelectedTabPosition = 0;
- private String selectedTabId;
- private int selectedIndex;
-
- public TabWidget(final SelectionHandler<Integer> selectionListener) {
- nbTab = 0;
- initWidget(tab);
- tab.setWidth("100%");
-
- tab.addSelectionHandler(new SelectionHandler<Integer>() {
- public void onSelection(SelectionEvent<Integer> event) {
- selectedTabId = tab.getWidget(event.getSelectedItem()).getElement().getId().replace("_tab_content", "");
- selectedIndex = event.getSelectedItem();
- selectionListener.onSelection(event);
- }
- });
-
- }
-
- public String getSelectedTabId() {
- return selectedTabId;
- }
-
- public Widget getSelectedWidget() {
- return tab.getWidget(selectedIndex);
- }
-
- public void addTab(Widget widget, String tabName, String id) {
- widget.getElement().setId(id + "_tab_content");
- tab.add(widget, createTabLabel(tabName, id));
- if (nbTab.equals(defaultSelectedTabPosition)) {
- tab.selectTab(defaultSelectedTabPosition);
- }
- nbTab++;
- }
-
- private Label createTabLabel(String tabName, String id) {
- Label tabLabel = new Label(tabName);
- tabLabel.getElement().setId(id + "_tab_title");
- tabLabel.addStyleName("tab_title");
- return tabLabel;
- }
-
-}
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/GwtClouds.gwt.xml b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/GwtClouds.gwt.xml
deleted file mode 100644
index cde524c0f66..00000000000
--- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/GwtClouds.gwt.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<module>
- <inherits name="com.google.gwt.user.User"/>
- <inherits name="com.google.gwt.json.JSON"/>
- <inherits name="com.google.gwt.http.HTTP"/>
- <inherits name="org.sonar.api.web.gwt.Sonar"/>
-
- <stylesheet src="clouds.css"/>
-
- <entry-point class="org.sonar.plugins.core.clouds.client.GwtClouds"/>
-
-</module>
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/GwtCloudsDev.gwt.xml b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/GwtCloudsDev.gwt.xml
deleted file mode 100644
index 9d3f64f412a..00000000000
--- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/GwtCloudsDev.gwt.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<module rename-to="org.sonar.plugins.core.clouds.GwtClouds">
- <inherits name="org.sonar.plugins.core.clouds.GwtClouds"/>
- <inherits name="org.sonar.SonarDev"/>
-
- <entry-point class="org.sonar.plugins.core.clouds.client.GwtClouds"/>
-</module>
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/public/clouds.css b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/public/clouds.css
deleted file mode 100644
index c2790c3c95c..00000000000
--- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/public/clouds.css
+++ /dev/null
@@ -1,29 +0,0 @@
-.tag {
- padding: 0px;
- cursor: pointer;
-}
-
-.inline{
- display: inline;
-}
-
-a {
- border-bottom: 0 none;
-}
-
-.tab_title {
- white-space: nowrap;
-}
-
-.metricSelectBox {
- float: right;
-}
-
-.metricSelectBox .labelText {
- padding-top: 2px;
- padding-right: 5px;
-
-}
-
-
-
diff --git a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/public/test.html b/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/public/test.html
deleted file mode 100644
index c4292e18121..00000000000
--- a/plugins/sonar-core-gwt/src/main/resources/org/sonar/plugins/core/clouds/public/test.html
+++ /dev/null
@@ -1,39 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
-
-<html>
-<head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <title>Clouds xxx</title>
- <link href="http://localhost:9000/dev/stylesheets/yui-2.6.0.css" media="all" rel="Stylesheet" type="text/css"/>
- <link href="http://localhost:9000/dev/stylesheets/style.css" media="all" rel="Stylesheet" type="text/css"/>
- <script src="http://localhost:9000/dev/javascripts/application.js" type="text/javascript"></script>
- <script src="http://localhost:9000/dev/javascripts/prototype.js" type="text/javascript"></script>
- <script src="http://localhost:9000/dev/javascripts/scriptaculous.js" type="text/javascript"></script>
-</head>
-
-<body>
-<script type="text/javascript">
- var config = {
- "sonar_url": "http://localhost:9000/dev",
- "resource_key" : "org.codehaus.sonar:sonar-plugin-api",
- "permalink_url_base" : "http://localhost:9000/dev/views/project/org.codehaus.sonar:sonar/org.sonar.plugins.core.clouds.GwtClouds?foo=bar"
- };
-</script>
-
-<div class="error" id="error" style="display:none"><span id="errormsg"></span> &nbsp;&nbsp;[<a href="#"
- onclick="javascript:$('error').hide();return false;">hide</a>]
-</div>
-<div class="warning" id="warning" style="display:none"><span id="warningmsg"></span> &nbsp;&nbsp;[<a href="#"
- onclick="javascript:$('warning').hide();return false;">hide</a>]
-</div>
-<div class="notice" id="info" style="display:none"><span id="infomsg"></span> &nbsp;&nbsp;[<a href="#"
- onclick="javascript:$('info').hide();return false;">hide</a>]
-</div>
-
-<div id="gwtpage">
-</div>
-
-<script type="text/javascript" language="javascript" src="org.sonar.plugins.core.clouds.GwtClouds.nocache.js"></script>
-</body>
-</html> \ No newline at end of file
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
index 61d8a1380e1..08817c0ac0b 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/CorePlugin.java
@@ -31,7 +31,6 @@ import org.sonar.plugins.core.batch.MavenInitializer;
import org.sonar.plugins.core.charts.DistributionAreaChart;
import org.sonar.plugins.core.charts.DistributionBarChart;
import org.sonar.plugins.core.charts.XradarChart;
-import org.sonar.plugins.core.clouds.Clouds;
import org.sonar.plugins.core.colorizers.JavaColorizerFormat;
import org.sonar.plugins.core.duplicationsviewer.DuplicationsViewerDefinition;
import org.sonar.plugins.core.hotspots.Hotspots;
@@ -172,7 +171,6 @@ public class CorePlugin extends SonarPlugin {
// pages
extensions.add(DuplicationsViewerDefinition.class);
extensions.add(TestsViewerDefinition.class);
- extensions.add(Clouds.class);
extensions.add(Hotspots.class);
// widgets
diff --git a/plugins/sonar-squid-java-plugin/pom.xml b/plugins/sonar-squid-java-plugin/pom.xml
index 56ec735923a..3af4a6616c3 100644
--- a/plugins/sonar-squid-java-plugin/pom.xml
+++ b/plugins/sonar-squid-java-plugin/pom.xml
@@ -53,6 +53,11 @@
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</exclusion>
+ <exclusion>
+ <!-- See SONAR-2512 -->
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils-core</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
diff --git a/pom.xml b/pom.xml
index bf501846701..d10e9aba268 100644
--- a/pom.xml
+++ b/pom.xml
@@ -337,6 +337,23 @@
</rules>
</configuration>
</execution>
+ <execution>
+ <id>enforce-banned-dependencies</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <bannedDependencies>
+ <searchTransitive>true</searchTransitive>
+ <message>commons-beanutils should be used instead</message>
+ <excludes>
+ <exclude>commons-beanutils:commons-beanutils-core</exclude>
+ </excludes>
+ </bannedDependencies>
+ </rules>
+ </configuration>
+ </execution>
</executions>
</plugin>
<plugin>
@@ -526,6 +543,12 @@
<version>1.3</version>
</dependency>
<dependency>
+ <!-- See SONAR-2512 -->
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.8.3</version>
+ </dependency>
+ <dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.6</version>
@@ -534,6 +557,11 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
+ <exclusion>
+ <!-- See SONAR-2512 -->
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils-core</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<dependency>
diff --git a/quick-build.bat b/quick-build.bat
index 8330a14032b..84f70ef861b 100644
--- a/quick-build.bat
+++ b/quick-build.bat
@@ -1,2 +1,2 @@
set MAVEN_OPTS=-Xmx768m -XX:MaxPermSize=256m
-mvn clean install -Dtest=false -DfailIfNoTests=false -Pdev
+mvn clean install -Dtest=false -DfailIfNoTests=false -Pdev %*
diff --git a/quick-build.sh b/quick-build.sh
index 69158699406..1ab7db6ea40 100755
--- a/quick-build.sh
+++ b/quick-build.sh
@@ -9,4 +9,4 @@ echo ''
echo '-------------------------------------------------'
# it is recommended to use maven 3 for faster builds
-mvn clean install -Dtest=false -DfailIfNoTests=false -Pdev
+mvn clean install -Dtest=false -DfailIfNoTests=false -Pdev $*
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapClassLoader.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapClassLoader.java
deleted file mode 100644
index ca00f9a0691..00000000000
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapClassLoader.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.batch.bootstrap;
-
-import org.sonar.api.utils.SonarException;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-
-/**
- * ClassLoader extended with the JDBC Driver hosted on the server-side.
- */
-public class BootstrapClassLoader {
-
- private URLClassLoader classLoader;
-
- public BootstrapClassLoader(ArtifactDownloader extensionDownloader) {
- this(extensionDownloader.downloadJdbcDriver());
- }
-
- BootstrapClassLoader(File jdbcDriver) {
- try {
- ClassLoader parentClassLoader = BootstrapClassLoader.class.getClassLoader();
- classLoader = URLClassLoader.newInstance(new URL[]{jdbcDriver.toURI().toURL()}, parentClassLoader);
-
- } catch (MalformedURLException e) {
- throw new SonarException("Fail to get URL of : " + jdbcDriver.getAbsolutePath(), e);
- }
- }
-
- public URLClassLoader getClassLoader() {
- return classLoader;
- }
-}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java
index 0eaf338f8fa..fc09ef25dd0 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BootstrapModule.java
@@ -55,9 +55,9 @@ public class BootstrapModule extends Module {
addComponent(TempDirectories.class);// registered here because used by BootstrapClassLoader
addComponent(HttpDownloader.class);// registered here because used by BootstrapClassLoader
addComponent(ArtifactDownloader.class);// registered here because used by BootstrapClassLoader
- addComponent(BootstrapClassLoader.class);
+ addComponent(JdbcDriverHolder.class);
- URLClassLoader bootstrapClassLoader = getComponent(BootstrapClassLoader.class).getClassLoader();
+ URLClassLoader bootstrapClassLoader = getComponent(JdbcDriverHolder.class).getClassLoader();
// set as the current context classloader for hibernate, else it does not find the JDBC driver.
Thread.currentThread().setContextClassLoader(bootstrapClassLoader);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcDriverHolder.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcDriverHolder.java
new file mode 100644
index 00000000000..427ac20e3ab
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcDriverHolder.java
@@ -0,0 +1,132 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.batch.bootstrap;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.sonar.api.utils.SonarException;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.List;
+
+/**
+ * Contains and provides class loader extended with the JDBC Driver hosted on the server-side.
+ */
+public class JdbcDriverHolder {
+
+ private static Logger LOG = LoggerFactory.getLogger(JdbcDriverHolder.class);
+ private JdbcDriverClassLoader classLoader;
+
+ public JdbcDriverHolder(ArtifactDownloader extensionDownloader) {
+ this(extensionDownloader.downloadJdbcDriver());
+ }
+
+ JdbcDriverHolder(File jdbcDriver) {
+ try {
+ ClassLoader parentClassLoader = JdbcDriverHolder.class.getClassLoader();
+ classLoader = new JdbcDriverClassLoader(jdbcDriver.toURI().toURL(), parentClassLoader);
+
+ } catch (MalformedURLException e) {
+ throw new SonarException("Fail to get URL of : " + jdbcDriver.getAbsolutePath(), e);
+ }
+ }
+
+ public URLClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ /**
+ * This method automatically invoked by PicoContainer and deregisters JDBC drivers, which were forgotten.
+ * <p>
+ * Dynamically loaded JDBC drivers can not be simply used and this is a well known problem of {@link java.sql.DriverManager},
+ * so <a href="http://stackoverflow.com/questions/288828/how-to-use-a-jdbc-driver-from-an-arbitrary-location">workaround is to use proxy</a>.
+ * However DriverManager also contains memory leak, thus not only proxy, but also original driver must be deregistered,
+ * otherwise our class loader would be kept in memory.
+ * </p>
+ * <p>
+ * This operation contains unnecessary complexity because:
+ * <ul>
+ * <li>DriverManager checks the class loader of the calling class. Thus we can't simply ask it about deregistration.</li>
+ * <li>We can't use reflection against DriverManager, since it would create a dependency on DriverManager implementation,
+ * which can be changed (like it was done - compare Java 1.5 and 1.6).</li>
+ * <li>So we use companion - {@link JdbcLeakPrevention}. But we can't just create an instance,
+ * since it will be loaded by parent class loader and again will not pass DriverManager's check.
+ * So, we load the bytes via our parent class loader, but define the class with this class loader
+ * thus JdbcLeakPrevention looks like our class to the DriverManager.</li>
+ * </li>
+ * </p>
+ */
+ public void stop() {
+ classLoader.clearReferencesJdbc();
+ classLoader = null;
+ }
+
+ private static class JdbcDriverClassLoader extends URLClassLoader {
+
+ public JdbcDriverClassLoader(URL jdbcDriver, ClassLoader parent) {
+ super(new URL[] { jdbcDriver }, parent);
+ }
+
+ public void clearReferencesJdbc() {
+ InputStream is = getResourceAsStream("org/sonar/batch/bootstrap/JdbcLeakPrevention.class");
+ byte[] classBytes = new byte[2048];
+ int offset = 0;
+ try {
+ int read = is.read(classBytes, offset, classBytes.length - offset);
+ while (read > -1) {
+ offset += read;
+ if (offset == classBytes.length) {
+ // Buffer full - double size
+ byte[] tmp = new byte[classBytes.length * 2];
+ System.arraycopy(classBytes, 0, tmp, 0, classBytes.length);
+ classBytes = tmp;
+ }
+ read = is.read(classBytes, offset, classBytes.length - offset);
+ }
+
+ Class<?> lpClass = defineClass("org.sonar.batch.bootstrap.JdbcLeakPrevention", classBytes, 0, offset, this.getClass().getProtectionDomain());
+ Object obj = lpClass.newInstance();
+
+ @SuppressWarnings("unchecked")
+ List<String> driverNames = (List<String>) obj.getClass().getMethod("clearJdbcDriverRegistrations").invoke(obj);
+
+ for (String name : driverNames) {
+ LOG.debug("To prevent a memory leak, the JDBC Driver [{}] has been forcibly deregistered", name);
+ }
+ } catch (Exception e) {
+ LOG.warn("JDBC driver deregistration failed", e);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException ioe) {
+ LOG.warn(ioe.getMessage(), ioe);
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcLeakPrevention.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcLeakPrevention.java
new file mode 100644
index 00000000000..6da6514d45e
--- /dev/null
+++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcLeakPrevention.java
@@ -0,0 +1,64 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar 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.
+ *
+ * Sonar 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 Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+package org.sonar.batch.bootstrap;
+
+import java.sql.Driver;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.List;
+
+/**
+ * Companion of {@link JdbcDriverHolder} and allows it to deregister JDBC drivers.
+ * <p>
+ * Some hacks are involved in the loading of the class - see {@link JdbcDriverHolder#stop()},
+ * so this class can refer to classes only from java.* package and must not be referred from other classes.
+ * Placement and naming of this class and methods are very important, since it loaded and invoked via reflection.
+ * </p>
+ */
+public class JdbcLeakPrevention {
+
+ /**
+ * @return list of names of deregistered drivers
+ */
+ public List<String> clearJdbcDriverRegistrations() throws SQLException {
+ List<String> driverNames = new ArrayList<String>();
+ HashSet<Driver> originalDrivers = new HashSet<Driver>();
+ Enumeration<Driver> drivers = DriverManager.getDrivers();
+ while (drivers.hasMoreElements()) {
+ originalDrivers.add(drivers.nextElement());
+ }
+ drivers = DriverManager.getDrivers();
+ while (drivers.hasMoreElements()) {
+ Driver driver = drivers.nextElement();
+ if (driver.getClass().getClassLoader() != this.getClass().getClassLoader()) {
+ continue;
+ }
+ if (originalDrivers.contains(driver)) {
+ driverNames.add(driver.getClass().getCanonicalName());
+ }
+ DriverManager.deregisterDriver(driver);
+ }
+ return driverNames;
+ }
+
+}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
index 4962be2b8e6..dd59bb2009d 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/components/PastSnapshotFinder.java
@@ -63,8 +63,8 @@ public class PastSnapshotFinder implements BatchExtension {
case 1: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_1; break;
case 2: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2; break;
case 3: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_3; break;
- case 4: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4; break;
- case 5: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5; break;// NOSONAR false-positive: constant 5 is the same than 4 (empty string)
+ case 4: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4; break; // NOSONAR false-positive: constant 4 is the same than 5 (empty string)
+ case 5: defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5; break; // NOSONAR false-positive: constant 5 is the same than 4 (empty string)
}
return conf.getString(CoreProperties.TIMEMACHINE_PERIOD_PREFIX + index, defaultValue);
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BootstrapClassLoaderTest.java b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BootstrapClassLoaderTest.java
index b28a4c33431..dfee29db761 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BootstrapClassLoaderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/bootstrap/BootstrapClassLoaderTest.java
@@ -37,7 +37,7 @@ public class BootstrapClassLoaderTest {
assertNull(getClass().getClassLoader().getResource("foo/foo.txt"));
URL url = getClass().getResource("/org/sonar/batch/bootstrap/BootstrapClassLoaderTest/foo.jar");
- BootstrapClassLoader classloader = new BootstrapClassLoader(new File(url.toURI()));
+ JdbcDriverHolder classloader = new JdbcDriverHolder(new File(url.toURI()));
assertNotNull(classloader.getClassLoader());
assertNotNull(classloader.getClassLoader().getResource("foo/foo.txt"));
diff --git a/sonar-core/src/main/java/org/sonar/jpa/session/DriverDatabaseConnector.java b/sonar-core/src/main/java/org/sonar/jpa/session/DriverDatabaseConnector.java
index d30892f14b4..00e91fd8f38 100644
--- a/sonar-core/src/main/java/org/sonar/jpa/session/DriverDatabaseConnector.java
+++ b/sonar-core/src/main/java/org/sonar/jpa/session/DriverDatabaseConnector.java
@@ -27,11 +27,13 @@ import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.SQLException;
+import java.util.Enumeration;
import java.util.Properties;
public class DriverDatabaseConnector extends AbstractDatabaseConnector {
private ClassLoader classloader;
+ private boolean driverProxyRegistered = false;
public DriverDatabaseConnector(Configuration configuration) {
super(configuration, true);
@@ -74,25 +76,53 @@ public class DriverDatabaseConnector extends AbstractDatabaseConnector {
}
public Connection getConnection() throws SQLException {
- try {
- /*
- The sonar batch downloads the JDBC driver in a separated classloader.
- This is a well-know problem of java.sql.DriverManager. The workaround
- is to use a proxy.
- See http://stackoverflow.com/questions/288828/how-to-use-a-jdbc-driver-from-an-arbitrary-location
- */
- Driver driver = (Driver)classloader.loadClass(getDriver()).newInstance();
- DriverManager.registerDriver(new DriverProxy(driver));
-
- } catch (Exception e) {
- SQLException ex = new SQLException("SQL driver not found " + getDriver());
- ex.initCause(e);
- throw ex;
+ /*
+ * The Sonar batch downloads the JDBC driver in a separated class loader.
+ * This is a well-know problem of java.sql.DriverManager. The workaround
+ * is to use a proxy.
+ * See http://stackoverflow.com/questions/288828/how-to-use-a-jdbc-driver-from-an-arbitrary-location
+ */
+ if (!driverProxyRegistered) {
+ driverProxyRegistered = true;
+ try {
+ Driver driver = (Driver) classloader.loadClass(getDriver()).newInstance();
+ DriverManager.registerDriver(new DriverProxy(driver));
+ } catch (Exception e) {
+ SQLException ex = new SQLException("SQL driver not found " + getDriver());
+ throw (SQLException) ex.initCause(e);
+ }
}
return DriverManager.getConnection(getUrl(), getUsername(), getPassword());
}
@Override
+ public void stop() {
+ super.stop();
+
+ deregisterDriverProxy();
+ }
+
+ /**
+ * Due to memory leak in DriverManager we also should deregister original driver,
+ * but we can't do it here, because DriverManager checks the class loader of the calling class.
+ * So actually we might have a memory leak, but it supposed to be handled by Sonar batch.
+ */
+ private void deregisterDriverProxy() {
+ Enumeration<Driver> drivers = DriverManager.getDrivers();
+ while (drivers.hasMoreElements()) {
+ Driver driver = drivers.nextElement();
+ if (driver instanceof DriverProxy) {
+ try {
+ DriverManager.deregisterDriver(driver);
+ LOG.debug("JDBC Driver [{}] deregistered", driver);
+ } catch (SQLException e) {
+ LOG.warn("JDBC driver deregistration failed", e);
+ }
+ }
+ }
+ }
+
+ @Override
public void setupEntityManagerFactory(Properties factoryProps) {
factoryProps.put("hibernate.connection.url", getUrl());
factoryProps.put("hibernate.connection.driver_class", getDriver());
@@ -113,7 +143,7 @@ final class DriverProxy implements Driver {
DriverProxy(Driver target) {
if (target == null) {
- throw new NullPointerException();
+ throw new IllegalArgumentException();
}
this.target = target;
}
@@ -126,9 +156,7 @@ final class DriverProxy implements Driver {
return target.acceptsURL(url);
}
- public Connection connect(
- String url, Properties info
- ) throws SQLException {
+ public Connection connect(String url, Properties info) throws SQLException {
return target.connect(url, info);
}
@@ -140,9 +168,7 @@ final class DriverProxy implements Driver {
return target.getMinorVersion();
}
- public java.sql.DriverPropertyInfo[] getPropertyInfo(
- String url, Properties info
- ) throws SQLException {
+ public java.sql.DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
return target.getPropertyInfo(url, info);
}
@@ -168,4 +194,4 @@ final class DriverProxy implements Driver {
org.sonar.jpa.session.DriverProxy other = (org.sonar.jpa.session.DriverProxy) obj;
return this.target.equals(other.target);
}
-} \ No newline at end of file
+}
diff --git a/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java b/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java
index ab3ee2417d0..0ae8a5e516e 100644
--- a/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java
+++ b/sonar-core/src/main/java/org/sonar/jpa/session/JpaDatabaseSession.java
@@ -160,7 +160,7 @@ public class JpaDatabaseSession extends DatabaseSession {
startTransaction();
return entityManager.createQuery(hql);
}
-
+
@Override
public Query createNativeQuery(String sql) {
startTransaction();
@@ -214,8 +214,7 @@ public class JpaDatabaseSession extends DatabaseSession {
} catch (NonUniqueResultException ex) {
NonUniqueResultException e = new NonUniqueResultException("Expected single result for entitiy " + entityClass.getSimpleName()
+ " with criterias : " + StringUtils.join(criterias, ","));
- e.initCause(ex);
- throw e;
+ throw (NonUniqueResultException) e.initCause(ex);
}
}
diff --git a/sonar-plugin-api/pom.xml b/sonar-plugin-api/pom.xml
index f6ca09bc860..d6d030387f7 100644
--- a/sonar-plugin-api/pom.xml
+++ b/sonar-plugin-api/pom.xml
@@ -10,19 +10,6 @@
<packaging>jar</packaging>
<name>Sonar :: Plugin API</name>
<build>
- <resources>
- <!-- sources of Sonar GWT library -->
- <resource>
- <directory>src/main/java</directory>
- <includes>
- <include>**/org/sonar/api/web/gwt/**/*</include>
- </includes>
- </resource>
- <resource>
- <directory>src/main/resources</directory>
- </resource>
- </resources>
-
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -137,16 +124,6 @@
<artifactId>xpp3</artifactId>
</dependency>
<dependency>
- <groupId>com.google.gwt</groupId>
- <artifactId>gwt-user</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>com.google.gwt</groupId>
- <artifactId>gwt-incubator</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>woodstox-core-lgpl</artifactId>
</dependency>
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/AbstractPage.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/AbstractPage.java
deleted file mode 100644
index 08ecfa30815..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/AbstractPage.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client;
-
-import com.google.gwt.core.client.EntryPoint;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.ui.RootPanel;
-import com.google.gwt.user.client.ui.Widget;
-
-/**
- * @deprecated since 2.0, use the lib sonar-gwt-api
- */
-@Deprecated
-public abstract class AbstractPage implements EntryPoint {
-
- protected void displayView(Widget widget) {
- Element loading = DOM.getElementById("loading");
- if (loading != null) {
- DOM.removeChild(getRootPanel().getElement(), loading);
- }
- getRootPanel().add(widget);
- }
-
- protected RootPanel getRootPanel() {
- RootPanel rootPanel = RootPanel.get("gwtpage-" + GWT.getModuleName());
- if (rootPanel == null) {
- rootPanel = RootPanel.get("gwtpage");
- }
- return rootPanel;
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/ResourceDictionary.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/ResourceDictionary.java
deleted file mode 100644
index ea08ac8c8dd..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/ResourceDictionary.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client;
-
-import com.google.gwt.i18n.client.Dictionary;
-
-/**
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public final class ResourceDictionary {
-
- public final static String CONF_PERMALINK_BASE = "permalink_url_base";
- public final static String CONF_RESOURCE_KEY = "resource_key";
- public final static String CONF_V_RESOURCE_KEY = "viewer_resource_key";
- public final static String CONF_V_PLUGIN_KEY = "viewer_plugin_key";
- public final static String CONF_V_METRIC_KEY = "metric";
-
- private ResourceDictionary() {
- }
-
- public static String getPermaLinkURLBase() {
- return Utils.getConfiguration(CONF_PERMALINK_BASE);
- }
-
- public static String getResourceKey() {
- return Utils.getConfiguration(CONF_RESOURCE_KEY);
- }
-
- public static String getViewerResourceKey() {
- return Utils.getConfiguration(CONF_V_RESOURCE_KEY);
- }
-
- public static String getViewerPluginKey() {
- return Utils.getConfiguration(CONF_V_PLUGIN_KEY);
- }
-
- public static String getViewerMetricKey() {
- return Utils.getConfiguration(CONF_V_METRIC_KEY);
- }
-
- public static Dictionary getResourceViewers() {
- return Dictionary.getDictionary("resource_viewers");
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/Utils.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/Utils.java
deleted file mode 100644
index 97f6b9d6a8f..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/Utils.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client;
-
-import com.google.gwt.i18n.client.Dictionary;
-import com.google.gwt.i18n.client.NumberFormat;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Element;
-import com.google.gwt.user.client.Window;
-import org.sonar.api.web.gwt.client.webservices.Resource;
-
-import java.util.Set;
-
-/**
- * A class of web utility
- *
- * @since 1.10
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public final class Utils {
- private Utils() {
- }
-
- public static String getConfiguration(String key) {
- return getConfiguration(key, null);
- }
-
- public static String getConfiguration(String key, String defaultValue) {
- String result = getDictionaryEntry("config", key);
- if (result == null) {
- result = defaultValue;
- }
- return result;
- }
-
- public static native void setConfiguration(String key, String val) /*-{
- $wnd.config[key] = val;
- }-*/;
-
- public static String getRequestParameter(String key) {
- return getDictionaryEntry("request_parameters", key);
- }
-
- public static Set<String> getConfigurationKeys() {
- return getDictionaryKeys("config");
- }
-
- public static Set<String> getRequestParameterNames() {
- return getDictionaryKeys("request_parameters");
- }
-
- private static String getDictionaryEntry(String dictionaryName, String key) {
- try {
- Dictionary dic = Dictionary.getDictionary(dictionaryName);
- if (dic != null) {
- return dic.get(key);
- }
- return null;
-
- } catch (Exception e) {
- return null;
- }
- }
-
- private static Set<String> getDictionaryKeys(String dictionaryName) {
- Dictionary dic = Dictionary.getDictionary(dictionaryName);
- if (dic != null) {
- return dic.keySet();
- }
- return null;
- }
-
- public static String widgetGWTIdJSEncode(String widgetGWTId) {
- return widgetGWTId.replace('.', '_');
- }
-
- public static String getServerUrl() {
- return getConfiguration("sonar_url");
- }
-
- public static String getServerApiUrl() {
- return getServerUrl() + "/api";
- }
-
- public static String escapeHtml(String maybeHtml) {
- final Element div = DOM.createDiv();
- DOM.setInnerText(div, maybeHtml);
- return DOM.getInnerHTML(div);
- }
-
- public static String formatPercent(String percentage) {
- return percentage == null || percentage.equals("") ? "" : formatPercent(new Double(percentage));
- }
-
- public static String formatPercent(double percentage) {
- return NumberFormat.getFormat("0.0").format(percentage) + "%";
- }
-
- public static String formatNumber(String number) {
- return number == null || number.equals("") ? "" : formatNumber(new Double(number));
- }
-
- public static String formatNumber(double number) {
- return NumberFormat.getDecimalFormat().format(number);
- }
-
- public static native void showError(String message) /*-{
- $wnd.error(message);
- }-*/;
-
- public static native void showWarning(String message) /*-{
- $wnd.warning(message);
- }-*/;
-
- public static native void showInfo(String message) /*-{
- $wnd.info(message);
- }-*/;
-
- /**
- * Display the resource in a popup.
- *
- * @param resource the resource to display, not null
- * @param metricKey the metric to highlight (optional : can be null)
- */
- public static void openResourcePopup(final Resource resource, final String metricKey) {
- String url = Utils.getServerUrl() + "/resource/index/" + resource.getId();
- if (metricKey != null) {
- url += "?" + ResourceDictionary.CONF_V_METRIC_KEY + "=" + metricKey;
- }
- Window.open(url, "resource", "height=800,width=900,scrollbars=1,resizable=1");
- }
-
- public static String getUrlToRuleDescription(final String ruleKey, final boolean showLayout) {
- return Utils.getServerUrl() + "/rules/show/" + ruleKey + "?layout=" + showLayout;
- }
-}
-
-
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/AbstractResourceQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/AbstractResourceQuery.java
deleted file mode 100644
index 07873b3eff2..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/AbstractResourceQuery.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-/**
- * @deprecated since 2.5
- */
-@Deprecated
-public abstract class AbstractResourceQuery<R extends ResponsePOJO> extends Query<R> {
-
- private String resourceKey;
-
- protected AbstractResourceQuery(String resourceKey) {
- super();
- this.resourceKey = resourceKey;
- }
-
- public String getResourceKey() {
- return resourceKey;
- }
-
- public void setResourceKey(String resourceKey) {
- this.resourceKey = resourceKey;
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/BaseQueryCallback.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/BaseQueryCallback.java
deleted file mode 100644
index bd997d099b9..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/BaseQueryCallback.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import org.sonar.api.web.gwt.client.Utils;
-import org.sonar.api.web.gwt.client.widgets.LoadingLabel;
-
-/**
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public abstract class BaseQueryCallback<P extends ResponsePOJO> implements QueryCallBack<P> {
-
- private LoadingLabel loading;
-
- public BaseQueryCallback() {
- this(null);
- }
-
- public BaseQueryCallback(LoadingLabel loading) {
- super();
- this.loading = loading;
- }
-
- public void onError(int errorCode, String errorMessage) {
- Utils.showError("Error received from server : " + errorCode + " - " + errorMessage);
- if (loading != null) {
- loading.removeFromParent();
- }
- }
-
- public void onTimeout() {
- Utils.showWarning("JSON query response timeout");
- if (loading != null) {
- loading.removeFromParent();
- }
- }
-
-} \ No newline at end of file
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JSONHandlerDispatcher.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JSONHandlerDispatcher.java
deleted file mode 100644
index 0ff29c002dc..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JSONHandlerDispatcher.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import com.google.gwt.core.client.JavaScriptObject;
-
-/**
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public abstract class JSONHandlerDispatcher<P extends ResponsePOJO> implements JsonUtils.JSONHandler {
-
- private QueryCallBack<P> callBack;
-
- public JSONHandlerDispatcher(QueryCallBack<P> callBack) {
- super();
- this.callBack = callBack;
- }
-
- public abstract P parseResponse(JavaScriptObject obj);
-
- public void onError(int errorCode, String errorMessage) {
- callBack.onError(errorCode, errorMessage);
- }
-
- public void onResponse(JavaScriptObject obj) {
- P responseObj = parseResponse(obj);
- callBack.onResponse(responseObj, obj);
- }
-
- public void onTimeout() {
- callBack.onTimeout();
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JsonUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JsonUtils.java
deleted file mode 100644
index a2d6552a254..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/JsonUtils.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import java.util.Date;
-
-import com.google.gwt.core.client.JavaScriptException;
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.http.client.URL;
-import com.google.gwt.i18n.client.DateTimeFormat;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONBoolean;
-import com.google.gwt.json.client.JSONNumber;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONString;
-import com.google.gwt.json.client.JSONValue;
-
-/**
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public final class JsonUtils {
- private static int requestId = 0;
-
- private JsonUtils() {
-
- }
-
- public interface JSONHandler {
- void onResponse(JavaScriptObject obj);
-
- void onTimeout();
-
- void onError(int errorCode, String errorMessage);
- }
-
- public static void requestJson(String url, JSONHandler handler) {
- if (!url.endsWith("&") && !url.endsWith("?")) {
- url += "&";
- }
- if (!url.contains("format=json")) {
- url += "format=json&";
- }
- if (!url.contains("callback=")) {
- //IMPORTANT : the url should ended with ?callback= or &callback= for JSONP calls
- url += "callback=";
- }
- makeJSONRequest(requestId++, URL.encode(url), handler);
- }
-
- public static native void makeJSONRequest(int requestId, String url, JSONHandler handler) /*-{
- var callback = "callback" + requestId;
-
- // create SCRIPT tag, and set SRC attribute equal to JSON feed URL + callback function name
- var script = document.createElement("script");
- script.setAttribute("src", url+callback);
- script.setAttribute("type", "text/javascript");
-
- window[callback] = function(jsonObj) {
- @org.sonar.api.web.gwt.client.webservices.JsonUtils::dispatchJSON(Lcom/google/gwt/core/client/JavaScriptObject;Lorg/sonar/api/web/gwt/client/webservices/JsonUtils$JSONHandler;)(jsonObj, handler);
- window[callback + "done"] = true;
- }
-
- setTimeout(function() {
- if (!window[callback + "done"]) {
- handler.@org.sonar.api.web.gwt.client.webservices.JsonUtils.JSONHandler::onTimeout();
- }
-
- // cleanup
- document.body.removeChild(script);
- if (window[callback]) {
- delete window[callback];
- }
- if (window[callback + "done"]) {
- delete window[callback + "done"];
- }
- }, 120000);
-
- document.body.appendChild(script);
- }-*/;
-
- public static void dispatchJSON(JavaScriptObject jsonObj, JSONHandler handler) {
- JSONObject obj = new JSONObject(jsonObj);
- if (obj.isObject() != null) {
- if (obj.containsKey("err_code")) {
- handler.onError(new Double(obj.get("err_code").isNumber().doubleValue()).intValue(),
- obj.get("err_msg").isString().stringValue());
- return;
- }
- }
- handler.onResponse(jsonObj);
- }
-
- public static String getString(JSONObject json, String field) {
- JSONValue jsonValue;
- JSONString jsonString;
- if ((jsonValue = json.get(field)) == null) {
- return null;
- }
- if ((jsonString = jsonValue.isString()) == null) {
- JSONNumber jsonNumber = jsonValue.isNumber();
- return jsonNumber != null ? jsonNumber.toString() : null;
- }
- return jsonString.stringValue();
- }
-
- public static Date getDate(JSONObject json, String field) {
- DateTimeFormat frmt = DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm:ssZ");
- String date = getString(json, field);
- if (date!=null && date.endsWith("Z") && date.length()>2) {
- // see SONAR-1182
- date = date.substring(0, date.length()-2) + "+00:00";
- }
- return frmt.parse(date);
- }
-
- public static Boolean getBoolean(JSONObject json, String field) {
- JSONValue jsonValue;
- JSONBoolean jsonBoolean;
- if ((jsonValue = json.get(field)) == null) {
- return null;
- }
- if ((jsonBoolean = jsonValue.isBoolean()) == null) {
- return null;
- }
- return jsonBoolean.booleanValue();
- }
-
- public static Double getDouble(JSONObject json, String field) {
- JSONValue jsonValue;
- JSONNumber jsonNumber;
- if ((jsonValue = json.get(field)) == null) {
- return null;
- }
- if ((jsonNumber = jsonValue.isNumber()) == null) {
- return null;
- }
- return jsonNumber.doubleValue();
- }
-
- public static Integer getInteger(JSONObject json, String field) {
- final Double d = getDouble(json, field);
- if (d != null) {
- return d.intValue();
- }
- return null;
- }
-
- public static JSONObject getArray(JSONValue json, int i) {
- if (json instanceof JSONArray) {
- return ((JSONArray) json).get(i).isObject();
- }
- if (json instanceof JSONObject) {
- return ((JSONObject) json).get(Integer.toString(i)).isObject();
- }
- throw new JavaScriptException("Not implemented");
- }
-
- public static int getArraySize(JSONValue array) {
- if (array instanceof JSONArray) {
- return ((JSONArray) array).size();
- }
- if (array instanceof JSONObject) {
- return ((JSONObject) array).size();
- }
- throw new JavaScriptException("Not implemented");
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java
deleted file mode 100644
index 51fa83584cb..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Measure.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import java.util.Date;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * @deprecated since 2.5, use {@link org.sonar.wsclient.services.Measure} instead.
- */
-@Deprecated
-public class Measure {
- private String metric;
- private String metricName;
- private Double value;
- private String formattedValue;
- private String data;
-
- private String ruleKey;
- private String ruleName;
- private String rulePriority;
-
- private Date date;
-
- public Measure() {
- }
-
- public Measure(String metric, Double value, String formattedValue) {
- this.metric = metric;
- this.value = value;
- this.formattedValue = formattedValue;
- }
-
- public String getMetric() {
- return metric;
- }
-
- public void setMetric(String metric) {
- this.metric = metric;
- }
-
- public Double getValue() {
- return value;
- }
-
- public void setValue(Double value) {
- this.value = value;
- }
-
- public String getFormattedValue() {
- return formattedValue;
- }
-
- public void setFormattedValue(String formattedValue) {
- this.formattedValue = formattedValue;
- }
-
- public String getData() {
- return data;
- }
-
- public Map<String, String> getDataAsMap() {
- Map<String, String> map = new TreeMap<String, String>();
- if (data != null) {
- String[] strings = data.split(";");
- for (String string : strings) {
- String[] keyValue = string.split("=");
- map.put(keyValue[0], keyValue[1]);
- }
- }
- return map;
-
- }
-
- public void setData(String data) {
- this.data = data;
- }
-
- public String getMetricName() {
- return metricName;
- }
-
- public void setMetricName(String metricName) {
- this.metricName = metricName;
- }
-
- public String getRuleKey() {
- return ruleKey;
- }
-
- public void setRuleKey(String s) {
- this.ruleKey = s;
- }
-
- public String getRuleName() {
- return ruleName;
- }
-
- public void setRuleName(String ruleName) {
- this.ruleName = ruleName;
- }
-
- /**
- * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
- */
- @Deprecated
- public String getRuleCategory() {
- return null;
- }
-
- public String getRulePriority() {
- return rulePriority;
- }
-
- public void setRulePriority(String rulePriority) {
- this.rulePriority = rulePriority;
- }
-
- public Date getDate() {
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
-
- @Override
- public String toString() {
- return "Measure{" +
- "metric='" + metric + '\'' +
- ", metric_name='" + metricName + '\'' +
- ", val='" + value + '\'' +
- ", f_val='" + formattedValue + '\'' +
- '}';
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/MetricsQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/MetricsQuery.java
deleted file mode 100644
index 628dc3daf23..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/MetricsQuery.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONObject;
-import org.sonar.api.web.gwt.client.Utils;
-import org.sonar.api.web.gwt.client.webservices.WSMetrics.MetricsList;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @deprecated since 2.5, use {@link org.sonar.wsclient.services.MetricQuery} instead.
- */
-@Deprecated
-public final class MetricsQuery extends Query<MetricsList> {
-
- private Boolean userManaged;
- private List<WSMetrics.Metric.ValueType> excludedTypes = new ArrayList<WSMetrics.Metric.ValueType>();
-
- public static MetricsQuery get() {
- return new MetricsQuery();
- }
-
- private MetricsQuery() {
- super();
- }
-
- public Boolean isUserManaged() {
- return userManaged;
- }
-
- public MetricsQuery setUserManaged(Boolean userManaged) {
- this.userManaged = userManaged;
- return this;
- }
-
- public MetricsQuery excludeTypes(WSMetrics.Metric.ValueType... types) {
- for (WSMetrics.Metric.ValueType valueType : types) {
- excludedTypes.add(valueType);
- }
- return this;
- }
-
- @Override
- public String toString() {
- return Utils.getServerApiUrl() + "/metrics?";
- }
-
- @Override
- public void execute(QueryCallBack<MetricsList> callback) {
- JsonUtils.requestJson(this.toString(), new JSONHandlerDispatcher<MetricsList>(callback) {
- @Override
- public MetricsList parseResponse(JavaScriptObject obj) {
- return parseMetrics(obj);
- }
- });
- }
-
- private MetricsList parseMetrics(JavaScriptObject json) {
- JSONArray array = new JSONArray(json);
- MetricsList list = new MetricsList();
- for (int i = 0; i < array.size(); i++) {
- JSONObject jsStock = array.get(i).isObject();
- if (jsStock != null) {
- WSMetrics.Metric m = parseMetric(jsStock);
- boolean skip = (isUserManaged() != null && (!isUserManaged() && m.isUserManaged())) || excludedTypes.contains(m.getType());
- if (!skip) {
- list.getMetrics().add(m);
- }
- }
- }
- return list;
- }
-
- private WSMetrics.Metric parseMetric(JSONObject json) {
- String key = JsonUtils.getString(json, "key");
- String name = JsonUtils.getString(json, "name");
- String description = JsonUtils.getString(json, "description");
- String domain = JsonUtils.getString(json, "domain");
- String type = JsonUtils.getString(json, "val_type");
- boolean qualitative = JsonUtils.getBoolean(json, "qualitative");
- boolean userManaged = JsonUtils.getBoolean(json, "user_managed");
- Integer direction = JsonUtils.getInteger(json, "direction");
- return new WSMetrics.Metric(key, name, description, domain, qualitative, userManaged, direction,
- WSMetrics.Metric.ValueType.valueOf(type));
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Query.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Query.java
deleted file mode 100644
index 7bbfacc2a2c..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Query.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-/**
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public abstract class Query<R extends ResponsePOJO> {
-
- public abstract void execute(final QueryCallBack<R> callback);
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/QueryCallBack.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/QueryCallBack.java
deleted file mode 100644
index 4f441b2be5b..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/QueryCallBack.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import com.google.gwt.core.client.JavaScriptObject;
-
-/**
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public interface QueryCallBack<RESPONSE_POJO extends ResponsePOJO> {
-
- void onResponse(RESPONSE_POJO response, JavaScriptObject jsonRawResponse);
-
- void onTimeout();
-
- void onError(int errorCode, String errorMessage);
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resource.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resource.java
deleted file mode 100644
index 17006192956..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resource.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import java.util.List;
-
-/**
- * @deprecated since 2.5, use {@link org.sonar.wsclient.services.Resource} instead.
- */
-@Deprecated
-public class Resource extends ResponsePOJO {
- public static final String SCOPE_SET = "PRJ";
- public static final String SCOPE_SPACE = "DIR";
- public static final String SCOPE_ENTITY = "FIL";
-
- @Deprecated
- public static final String SCOPE_PROJECT = SCOPE_SET;
- @Deprecated
- public static final String SCOPE_DIRECTORY = SCOPE_SPACE;
- @Deprecated
- public static final String SCOPE_FILE = SCOPE_ENTITY;
-
- public static final String QUALIFIER_PROJECT = "TRK";
- public static final String QUALIFIER_MODULE = "BRC";
- @Deprecated
- public static final String QUALIFIER_PROJECT_TRUNK = QUALIFIER_PROJECT;
- @Deprecated
- public static final String QUALIFIER_PROJECT_BRANCH = QUALIFIER_MODULE;
- public static final String QUALIFIER_PACKAGE = "PAC";
- public static final String QUALIFIER_DIRECTORY = "DIR";
- public static final String QUALIFIER_FILE = "FIL";
- public static final String QUALIFIER_CLASS = "CLA";
- public static final String QUALIFIER_UNIT_TEST = "UTS";
-
- private Integer id;
- private String key;
- private String name;
- private String longName;
- private String qualifier;
- private String scope;
- private String language;
- private Integer copy;
- private List<Measure> measures;
-
- public Resource() {
- }
-
- public Resource(Integer id, String key, String name, String scope, String qualifier, String language, Integer copy, List<Measure> measures) {
- this.id = id;
- this.key = key;
- this.name = name;
- this.qualifier = qualifier;
- this.scope = scope;
- this.language = language;
- this.measures = measures;
- this.copy = copy;
- }
-
- public Integer getId() {
- return id;
- }
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public String getName() {
- return name;
- }
-
- public String getName(boolean longFormatIfDefined) {
- if (longFormatIfDefined && longName != null && !"".equals(longName)) {
- return longName;
- }
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getLongName() {
- return longName;
- }
-
- public void setLongName(String longName) {
- this.longName = longName;
- }
-
- public String getQualifier() {
- return qualifier;
- }
-
- public void setQualifier(String qualifier) {
- this.qualifier = qualifier;
- }
-
- public String getScope() {
- return scope;
- }
-
- public void setScope(String scope) {
- this.scope = scope;
- }
-
- public String getLanguage() {
- return language;
- }
-
- public void setLanguage(String language) {
- this.language = language;
- }
-
- public Integer getCopy() {
- return copy;
- }
-
- public void setCopy(Integer copy) {
- this.copy = copy;
- }
-
- public List<Measure> getMeasures() {
- return measures;
- }
-
- public Measure getMeasure(WSMetrics.Metric metric) {
- if (measures != null) {
- for (Measure measure : measures) {
- if (measure.getMetric().equals(metric.getKey())) {
- return measure;
- }
- }
- }
- return null;
- }
-
- public boolean hasMeasure(WSMetrics.Metric metric) {
- return getMeasure(metric) != null;
- }
-
- public String getMeasureFormattedValue(WSMetrics.Metric metric, String defaultValue) {
- Measure measure = getMeasure(metric);
- if (measure != null) {
- return measure.getFormattedValue();
- }
- return defaultValue;
- }
-
- public void setMeasures(List<Measure> measures) {
- this.measures = measures;
- }
-
- public boolean matchesKey(String resourceKey) {
- return resourceKey != null && (getId().toString().equals(resourceKey) || getKey().equals(resourceKey));
- }
-
- @Override
- public String toString() {
- return "Resource{" +
- "id='" + id + '\'' +
- ", key='" + key + '\'' +
- ", name='" + name + '\'' +
- ", longName='" + longName + '\'' +
- ", scope='" + scope + '\'' +
- ", qualifier='" + qualifier + '\'' +
- ", language='" + language + '\'' +
- ", measures=" + measures +
- '}';
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resources.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resources.java
deleted file mode 100644
index 56cbfd9972c..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Resources.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import java.util.List;
-
-/**
- * @deprecated since 2.5
- */
-@Deprecated
-public class Resources extends ResponsePOJO {
-
- private List<Resource> resources;
-
- public Resources(List<Resource> resources) {
- super();
- this.resources = resources;
- }
-
- public List<Resource> getResources() {
- return resources;
- }
-
- public Resource firstResource() {
- return resources.size() > 0 ? resources.get(0) : null;
- }
-
- public boolean onceContainsMeasure(WSMetrics.Metric metric) {
- for (Resource resource : resources) {
- if (resource.getMeasure(metric) != null) {
- return true;
- }
- }
- return false;
- }
-
- public boolean allContainsMeasure(WSMetrics.Metric metric) {
- for (Resource resource : resources) {
- if (resource.getMeasure(metric) == null) {
- return false;
- }
- }
- return true;
- }
-
- public boolean isEmpty() {
- return resources == null || resources.isEmpty();
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java
deleted file mode 100644
index b984bfe0383..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResourcesQuery.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.json.client.JSONArray;
-import com.google.gwt.json.client.JSONObject;
-import com.google.gwt.json.client.JSONValue;
-import org.sonar.api.web.gwt.client.Utils;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @deprecated since 2.5, use {@link org.sonar.wsclient.services.ResourceQuery} instead
- */
-@Deprecated
-public final class ResourcesQuery extends AbstractResourceQuery<Resources> {
-
- public final static int DEPTH_UNLIMITED = -1;
-
- private Integer depth;
- private Integer limit;
- private String scopes;
- private String qualifiers;
- private String metrics;
- private String rules;
- private String rulePriorities;
- private boolean verbose = false;
-
- /**
- * Alias for build()
- */
- public static ResourcesQuery get(String resourceKey) {
- return new ResourcesQuery(resourceKey);
- }
-
- public static ResourcesQuery build(String resourceKey) {
- return new ResourcesQuery(resourceKey);
- }
-
- public static ResourcesQuery build() {
- return new ResourcesQuery(null);
- }
-
- private ResourcesQuery(String resourceKey) {
- super(resourceKey);
- }
-
- public ResourcesQuery setDepth(Integer depth) {
- this.depth = depth;
- return this;
- }
-
- public ResourcesQuery setRules(String s) {
- this.rules = s;
- return this;
- }
-
- public ResourcesQuery filterOnRules(boolean b) {
- return setRules(b ? "true" : "false");
- }
-
- public ResourcesQuery filterOnRulePriorities(boolean b) {
- return setRulePriorities(b ? "true" : "false");
- }
-
- /**
- * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
- */
- @Deprecated
- public ResourcesQuery filterOnRuleCategories(boolean b) {
- return this;
- }
-
- public ResourcesQuery setRulePriorities(String s) {
- this.rulePriorities = s;
- return this;
- }
-
- /**
- * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
- */
- @Deprecated
- public ResourcesQuery setRuleCategories(String s) {
- return this;
- }
-
- public ResourcesQuery setLimit(Integer limit) {
- this.limit = limit;
- return this;
- }
-
- public ResourcesQuery setScopes(String scopes) {
- this.scopes = scopes;
- return this;
- }
-
- public ResourcesQuery setVerbose(boolean verbose) {
- this.verbose = verbose;
- return this;
- }
-
- public ResourcesQuery setQualifiers(String qualifiers) {
- this.qualifiers = qualifiers;
- return this;
- }
-
- public ResourcesQuery setMetrics(List<WSMetrics.Metric> metrics) {
- this.metrics = getMetricsWSRequest(metrics);
- return this;
- }
-
- public ResourcesQuery setMetric(WSMetrics.Metric m) {
- this.metrics = m.getKey();
- return this;
- }
-
- public ResourcesQuery setMetric(String metricKey) {
- this.metrics = metricKey;
- return this;
- }
-
- private String getMetricsWSRequest(List<WSMetrics.Metric> metrics) {
- StringBuilder metricsDelimByComma = new StringBuilder(64);
- for (WSMetrics.Metric metric : metrics) {
- metricsDelimByComma.append(metric.getKey()).append(",");
- }
- return metricsDelimByComma.substring(0, metricsDelimByComma.length() - 1);
- }
-
- @Override
- public String toString() {
- String url = Utils.getServerApiUrl() + "/resources?";
- if (getResourceKey() != null) {
- url += "resource=" + getResourceKey() + "&";
- }
- if (metrics != null) {
- url += "metrics=" + metrics + "&";
- }
- if (scopes != null) {
- url += "scopes=" + scopes + "&";
- }
- if (qualifiers != null) {
- url += "qualifiers=" + qualifiers + "&";
- }
- if (depth != null) {
- url += "depth=" + depth + "&";
- }
- if (limit != null) {
- url += "limit=" + limit + "&";
- }
- if (rules != null) {
- url += "rules=" + rules + "&";
- }
- if (rulePriorities != null) {
- url += "rule_priorities=" + rulePriorities + "&";
- }
- if (verbose) {
- url += "verbose=true&";
- }
- return url;
- }
-
- @Override
- public void execute(QueryCallBack<Resources> callback) {
- JsonUtils.requestJson(this.toString(), new JSONHandlerDispatcher<Resources>(callback) {
- @Override
- public Resources parseResponse(JavaScriptObject obj) {
- return new Resources(parseResources(obj));
- }
- });
- }
-
- public static List<Resource> parseResources(JavaScriptObject json) {
- JSONArray array = new JSONArray(json);
- List<Resource> resources = new ArrayList<Resource>();
- for (int i = 0; i < array.size(); i++) {
- JSONObject jsStock = array.get(i).isObject();
- if (jsStock != null) {
- resources.add(parseResource(jsStock));
- }
- }
- return resources;
- }
-
- private static Resource parseResource(JSONObject json) {
- Double id = JsonUtils.getDouble(json, "id");
- String key = JsonUtils.getString(json, "key");
- String name = JsonUtils.getString(json, "name");
- String longName = JsonUtils.getString(json, "lname");
- String qualifier = JsonUtils.getString(json, "qualifier");
- String language = JsonUtils.getString(json, "lang");
- String scope = JsonUtils.getString(json, "scope");
- Integer copy = JsonUtils.getInteger(json, "copy");
- Date date = JsonUtils.getDate(json, "date");
-
- List<Measure> measures = null;
- JSONValue measuresJson;
- if ((measuresJson = json.get("msr")) != null) {
- measures = parseMeasures(measuresJson, date);
- }
-
- final Resource resource = new Resource(id.intValue(), key, name, scope, qualifier, language, copy, measures);
- resource.setLongName(longName);
- return resource;
- }
-
- private static List<Measure> parseMeasures(JSONValue measures, Date date) {
- List<Measure> projectMeasures = new ArrayList<Measure>();
- int len = JsonUtils.getArraySize(measures);
- for (int i = 0; i < len; i++) {
- JSONObject measure = JsonUtils.getArray(measures, i);
- if (measure != null) {
- Measure measureEntry = parseMeasure(measure, date);
- if (measureEntry != null) {
- projectMeasures.add(measureEntry);
- }
- }
- }
- return projectMeasures;
- }
-
- private static Measure parseMeasure(JSONObject measure, Date date) {
- String metric = JsonUtils.getString(measure, "key");
- if (metric == null) {
- return null;
- }
-
- final Measure m = new Measure(metric, JsonUtils.getDouble(measure, "val"), JsonUtils.getString(measure, "frmt_val"));
- m.setData(JsonUtils.getString(measure, "data"));
- String metricName = JsonUtils.getString(measure, "name");
- if (metricName != null) {
- m.setMetricName(metricName);
- }
-
- m.setRuleKey(JsonUtils.getString(measure, "rule_key"));
- m.setRuleName(JsonUtils.getString(measure, "rule_name"));
- m.setRulePriority(JsonUtils.getString(measure, "rule_priority"));
- m.setDate(date);
- return m;
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResponsePOJO.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResponsePOJO.java
deleted file mode 100644
index 6a54fffb941..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ResponsePOJO.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-/**
- * Marker class for WS query response objects
- */
-/**
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public abstract class ResponsePOJO {
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java
deleted file mode 100644
index dd4f5bf7873..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Rule.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-/**
- * @deprecated since 2.5
- */
-@Deprecated
-public class Rule extends ResponsePOJO {
- private String key;
- private String name;
-
- public Rule(String key, String name) {
- this.key = key;
- this.name = name;
- }
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
- */
- @Deprecated
- public String getCategory() {
- return null;
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SequentialQueries.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SequentialQueries.java
deleted file mode 100644
index 55301f41367..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SequentialQueries.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.google.gwt.core.client.JavaScriptObject;
-import com.google.gwt.user.client.Timer;
-
-/**
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public class SequentialQueries extends Query<VoidResponse> {
-
- private List<AjaxQuery<?>> queries = new ArrayList<AjaxQuery<?>>();
- private int sleepTimeBetweenCbChecks;
-
- private SequentialQueries(int sleepTimeBetweenCbChecks) {
- this.sleepTimeBetweenCbChecks = sleepTimeBetweenCbChecks;
- }
-
- public static SequentialQueries get() {
- return new SequentialQueries(50);
- }
-
- public static SequentialQueries get(int sleepTimeBetweenCbChecks) {
- return new SequentialQueries(sleepTimeBetweenCbChecks);
- }
-
- public <R extends ResponsePOJO> SequentialQueries add(Query<R> query, QueryCallBack<R> callback) {
- queries.add(new AjaxQuery<R>(query, callback));
- return this;
- }
-
- @Override
- public void execute(final QueryCallBack<VoidResponse> callback) {
- for (AjaxQuery<?> query : queries) {
- query.execute();
- }
- Timer queriesMonitor = new Timer() {
- @Override
- public void run() {
- boolean queriesExecuted = true;
- for (AjaxQuery<?> query : queries) {
- if (!query.isCompleted()) {
- queriesExecuted = false;
- break;
- }
- }
- if (queriesExecuted) {
- callback.onResponse(new VoidResponse(), null);
- cancel();
- }
- }
- };
- queriesMonitor.scheduleRepeating(sleepTimeBetweenCbChecks);
- }
-
- private class AjaxQuery<R extends ResponsePOJO> {
- private Query<R> query;
- private QueryCallBack<R> callback;
-
- private boolean completed = false;
-
- public AjaxQuery(Query<R> query, QueryCallBack<R> callback) {
- super();
- this.query = query;
- this.callback = callback;
- }
-
- private void execute() {
- QueryCallBack<R> proxy = new QueryCallBack<R>() {
- public void onError(int errorCode, String errorMessage) {
- callback.onError(errorCode, errorMessage);
- completed = true;
- }
-
- public void onResponse(R response, JavaScriptObject jsonRawResponse) {
- callback.onResponse(response, jsonRawResponse);
- completed = true;
- }
-
- public void onTimeout() {
- callback.onTimeout();
- completed = true;
- }
- };
- query.execute(proxy);
- }
-
- public boolean isCompleted() {
- return completed;
- }
-
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/VoidResponse.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/VoidResponse.java
deleted file mode 100644
index 6eee34741a2..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/VoidResponse.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-/**
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public class VoidResponse extends ResponsePOJO {
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java
deleted file mode 100644
index 5b8ffadd08a..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/WSMetrics.java
+++ /dev/null
@@ -1,247 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.webservices;
-
-import com.google.gwt.core.client.JavaScriptObject;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @deprecated since 2.8. Use sonar-gwt-api instead.
- */
-@Deprecated
-public final class WSMetrics {
-
- private WSMetrics() {
- }
-
- private final static List<Metric> DICTIONNARY = new ArrayList<Metric>();
-
- public static final Metric NCLOC = add(new Metric("ncloc"));
- public static final Metric LINES = add(new Metric("lines"));
- public static final Metric CLASSES = add(new Metric("classes"));
- public static final Metric PACKAGES = add(new Metric("packages"));
- public static final Metric FUNCTIONS = add(new Metric("functions"));
- public static final Metric ACCESSORS = add(new Metric("accessors"));
- public static final Metric FILES = add(new Metric("files"));
- public static final Metric DIRECTORIES = add(new Metric("directories"));
- public static final Metric PUBLIC_API = add(new Metric("public_api"));
-
- /* complexity */
- public static final Metric COMPLEXITY = add(new Metric("complexity"));
- public static final Metric CLASS_COMPLEXITY = add(new Metric("class_complexity"));
- public static final Metric FUNCTION_COMPLEXITY = add(new Metric("function_complexity"));
- public static final Metric FILE_COMPLEXITY = add(new Metric("file_complexity"));
- public static final Metric STATEMENTS = add(new Metric("statements"));
-
- public static final Metric CLASS_COMPLEXITY_DISTRIBUTION = add(new Metric("class_complexity_distribution"));
- public static final Metric FUNCTION_COMPLEXITY_DISTRIBUTION = add(new Metric("function_complexity_distribution"));
-
- /* comments */
- public static final Metric COMMENT_LINES = add(new Metric("comment_lines"));
- public static final Metric COMMENT_LINES_DENSITY = add(new Metric("comment_lines_density"));
- public static final Metric PUBLIC_DOCUMENTED_API_DENSITY = add(new Metric("public_documented_api_density"));
- public static final Metric PUBLIC_UNDOCUMENTED_API = add(new Metric("public_undocumented_api"));
- public static final Metric COMMENTED_OUT_CODE_LINES = add(new Metric("commented_out_code_lines"));
-
- /* unit tests */
- public static final Metric TESTS = add(new Metric("tests"));
- public static final Metric TESTS_EXECUTION_TIME = add(new Metric("test_execution_time"));
- public static final Metric TEST_ERRORS = add(new Metric("test_errors"));
- public static final Metric SKIPPED_TESTS = add(new Metric("skipped_tests"));
- public static final Metric TEST_FAILURES = add(new Metric("test_failures"));
- public static final Metric TEST_SUCCESS_DENSITY = add(new Metric("test_success_density"));
- public static final Metric TEST_DATA = add(new Metric("test_data"));
-
- /* coverage */
- public static final Metric COVERAGE = add(new Metric("coverage"));
- public static final Metric LINE_COVERAGE = add(new Metric("line_coverage"));
- public static final Metric UNCOVERED_LINES = add(new Metric("uncovered_lines"));
- public static final Metric BRANCH_COVERAGE = add(new Metric("branch_coverage"));
- public static final Metric UNCOVERED_CONDITIONS = add(new Metric("uncovered_conditions"));
- public static final Metric COVERAGE_LINE_HITS_DATA = add(new Metric("coverage_line_hits_data"));
- public static final Metric BRANCH_COVERAGE_HITS_DATA = add(new Metric("branch_coverage_hits_data"));
-
- /* duplicated lines */
- public static final Metric DUPLICATED_LINES = add(new Metric("duplicated_lines"));
- public static final Metric DUPLICATED_BLOCKS = add(new Metric("duplicated_blocks"));
- public static final Metric DUPLICATED_FILES = add(new Metric("duplicated_files"));
- public static final Metric DUPLICATED_LINES_DENSITY = add(new Metric("duplicated_lines_density"));
- public static final Metric DUPLICATIONS_DATA = add(new Metric("duplications_data"));
-
- /* coding rules */
- public static final Metric VIOLATIONS_DENSITY = add(new Metric("violations_density"));
- public static final Metric VIOLATIONS = add(new Metric("violations"));
- public static final Metric WEIGHTED_VIOLATIONS = add(new Metric("weighted_violations"));
-
- /* design */
- public static final Metric LCOM4 = add(new Metric("lcom4"));
- public static final Metric RFC = add(new Metric("rfc"));
-
- public static class MetricsList extends ResponsePOJO {
-
- private List<Metric> metrics = new ArrayList<Metric>();
-
- public List<Metric> getMetrics() {
- return metrics;
- }
- }
-
- /**
- * Generates a callback that will update the metrics definitions from the WSMetrics metrics constants list with data
- * received from a MetricsQuery call
- *
- * @param callback
- * @return
- */
- public static QueryCallBack<MetricsList> getUpdateMetricsFromServer(final QueryCallBack<MetricsList> callback) {
- return new QueryCallBack<MetricsList>() {
- public void onResponse(MetricsList response, JavaScriptObject jsonRawResponse) {
- for (Metric metric : response.getMetrics()) {
- Metric WSMetricConstant = get(metric.getKey());
- if (WSMetricConstant != null) {
- WSMetricConstant.updateFrom(metric);
- } else {
- add(metric);
- }
- }
- callback.onResponse(response, jsonRawResponse);
- }
-
- public void onError(int errorCode, String errorMessage) {
- callback.onError(errorCode, errorMessage);
- }
-
- public void onTimeout() {
- callback.onTimeout();
- }
- };
- }
-
- public static class Metric {
- public enum ValueType {
- INT, FLOAT, PERCENT, BOOL, STRING, MILLISEC, DATA, LEVEL, DISTRIB, RATING
- }
-
- private String key;
- private String name;
- private String description;
- private String domain;
- private boolean qualitative;
- private boolean userManaged;
- private int direction;
- private ValueType type;
-
- public Metric(String key) {
- super();
- this.key = key;
- }
-
- public Metric(String key, String name, String description, String domain,
- boolean qualitative, boolean userManaged, int direction, ValueType type) {
- super();
- this.key = key;
- this.name = name;
- this.description = description;
- this.domain = domain;
- this.qualitative = qualitative;
- this.userManaged = userManaged;
- this.direction = direction;
- this.type = type;
- }
-
- public void updateFrom(Metric metric) {
- this.name = metric.getName();
- this.description = metric.getDescription();
- this.domain = metric.getDomain();
- this.qualitative = metric.isQualitative();
- this.userManaged = metric.isUserManaged();
- this.direction = metric.getDirection();
- this.type = metric.getType();
- }
-
- public String getName() {
- return name;
- }
-
- public ValueType getType() {
- return type;
- }
-
- public String getDescription() {
- return description;
- }
-
- public String getDomain() {
- return domain;
- }
-
- public boolean isQualitative() {
- return qualitative;
- }
-
- public boolean isUserManaged() {
- return userManaged;
- }
-
- public int getDirection() {
- return direction;
- }
-
- public String getKey() {
- return key;
- }
-
- @Override
- public int hashCode() {
- return key.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Metric)) {
- return false;
- }
- if (this == obj) {
- return true;
- }
- Metric other = (Metric) obj;
- return key.equals(other.getKey());
- }
- }
-
- public static Metric add(Metric metric) {
- if (!DICTIONNARY.contains(metric)) {
- DICTIONNARY.add(metric);
- }
- return metric;
- }
-
- public static Metric get(String metricKey) {
- for (Metric metric : DICTIONNARY) {
- if (metric.getKey().equals(metricKey)) {
- return metric;
- }
- }
- return new Metric(metricKey);
- }
-
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/widgets/LoadingLabel.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/widgets/LoadingLabel.java
deleted file mode 100644
index 440485a24d8..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/widgets/LoadingLabel.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Sonar, open source software quality management tool.
- * Copyright (C) 2008-2011 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * Sonar 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.
- *
- * Sonar 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 Sonar; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
- */
-package org.sonar.api.web.gwt.client.widgets;
-
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HTML;
-
-public class LoadingLabel extends Composite {
- public LoadingLabel() {
- this("loading...");
- getElement().setId("loading");
- }
-
- public LoadingLabel(String text) {
- initWidget(new HTML("<div class='loading'>" + text + "</div>"));
- }
-}
diff --git a/sonar-server/src/main/java/org/sonar/server/filters/Filter.java b/sonar-server/src/main/java/org/sonar/server/filters/Filter.java
index 77dcb54b9ff..542a58b6fa7 100644
--- a/sonar-server/src/main/java/org/sonar/server/filters/Filter.java
+++ b/sonar-server/src/main/java/org/sonar/server/filters/Filter.java
@@ -60,8 +60,6 @@ public class Filter {
private boolean useMeasureValueToSort = true; // only if sortedMetricId is not null
private boolean ascendingSort = true;
-
-
public Filter setPath(Integer rootSnapshotId, Integer snapshotId, String snapshotPath, boolean isViewContext) {
this.baseSnapshotId = snapshotId;
if (rootSnapshotId == null) {
@@ -331,7 +329,7 @@ public class Filter {
}
public boolean isOnPeriod() {
- return periodIndex>0;
+ return periodIndex > 0;
}
static String getVariationColumn(int periodIndex) {
@@ -346,14 +344,15 @@ public class Filter {
return "variation_value_4";
case 5:
return "variation_value_5";
+ default:
+ return null;
}
- return null;
}
String getColumnToSort() {
String col = "text_value";
if (useMeasureValueToSort()) {
- col = (sortedByMeasureVariation==Boolean.TRUE ? getVariationColumn (periodIndex) : "value");
+ col = (sortedByMeasureVariation == Boolean.TRUE ? getVariationColumn(periodIndex) : "value");
}
return col;
}
@@ -361,7 +360,7 @@ public class Filter {
public boolean mustReturnEmptyResult() {
boolean hasCriterionOnVariation = false;
for (MeasureCriterion criterion : measureCriteria) {
- if (criterion.isVariation()==Boolean.TRUE) {
+ if (criterion.isVariation() == Boolean.TRUE) {
hasCriterionOnVariation = true;
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java b/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java
index 59f1219ba17..ed976159312 100644
--- a/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java
+++ b/sonar-server/src/main/java/org/sonar/server/ui/DefaultPages.java
@@ -28,7 +28,10 @@ import org.sonar.api.web.*;
*/
public final class DefaultPages {
- private static final View[] PAGES = {new SourceTab(), new CoverageTab(), new ViolationsTab()};
+ private static final View[] PAGES = { new SourceTab(), new CoverageTab(), new ViolationsTab() };
+
+ private DefaultPages() {
+ }
public static View[] getPages() {
return PAGES.clone();
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/cloud_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/cloud_controller.rb
new file mode 100644
index 00000000000..006184a5a26
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/cloud_controller.rb
@@ -0,0 +1,72 @@
+#
+# Sonar, open source software quality management tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+class CloudController < ApplicationController
+
+ SECTION=Navigation::SECTION_RESOURCE
+
+ def index
+ resource_key = params[:id]
+ @project = resource_key ? Project.by_key(resource_key) : nil
+ if @project.nil?
+ return render :text => "Resource [#{project_key}] not found", :status => 404
+ end
+ return access_denied unless has_role?(:user, @project)
+ @snapshot=@project.last_snapshot
+
+ @size_metric=Metric.by_key(params[:size]||'ncloc')
+ @color_metric=Metric.by_key(params[:color]||'coverage')
+
+ snapshot_conditions='snapshots.islast=:islast AND snapshots.scope=:scope AND snapshots.qualifier!=:test_qualifier AND
+ (snapshots.id=:sid OR (snapshots.root_snapshot_id=:root_sid AND snapshots.path LIKE :path))'
+ snapshot_values={
+ :islast => true,
+ :scope => 'FIL',
+ :test_qualifier => 'UTS',
+ :sid => @snapshot.id,
+ :root_sid => (@snapshot.root_snapshot_id || @snapshot.id),
+ :path => "#{@snapshot.path}#{@snapshot.id}.%"
+ }
+
+ @snapshots=Snapshot.find(:all, :conditions => [snapshot_conditions, snapshot_values], :include => 'project', :order => 'projects.name')
+
+ size_measures=ProjectMeasure.find(:all,
+ :select => 'project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.rule_priority,project_measures.text_value,project_measures.characteristic_id,project_measures.alert_status',
+ :joins => :snapshot,
+ :conditions => [snapshot_conditions + " AND project_measures.metric_id=#{@size_metric.id}", snapshot_values],
+ :order => 'project_measures.value')
+
+ color_measures=ProjectMeasure.find(:all,
+ :select => 'project_measures.id,project_measures.value,project_measures.metric_id,project_measures.snapshot_id,project_measures.rule_id,project_measures.rule_priority,project_measures.text_value,project_measures.characteristic_id,project_measures.alert_status',
+ :joins => :snapshot,
+ :conditions => [snapshot_conditions + " AND project_measures.metric_id=#{@color_metric.id}", snapshot_values],
+ :order => 'project_measures.value')
+
+ @size_measure_by_sid={}, @color_measure_by_sid={}
+ size_measures.each do |m|
+ @size_measure_by_sid[m.snapshot_id]=m
+ end
+ color_measures.each do |m|
+ @color_measure_by_sid[m.snapshot_id]=m
+ end
+ @min_size_value=(size_measures.empty? ? 0.0 : size_measures.first.value)
+ @max_size_value=(size_measures.empty? ? 0.0 : size_measures.last.value)
+ end
+
+end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
index 3d9cbeaf1ac..7cab30c34d5 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb
@@ -225,7 +225,7 @@ class ProfilesController < ApplicationController
end
@changes = ActiveRuleChange.find(:all, :conditions => ['profile_id=? and ?<profile_version and profile_version<=?', @profile.id, @since_version, @to_version], :order => 'id desc')
- @select_versions = versions.map {|u| ["version " + u.profile_version.to_s + " (" + u.change_date.strftime("%Y/%m/%d %H:%M:%S") + ")", u.profile_version]} | [["no version", 0]];
+ @select_versions = versions.map {|u| [ (u.profile_version == last_version ? "last " : "" ) + "version " + u.profile_version.to_s + " (" + l(u.change_date) + ")", u.profile_version]} | [["no version", 0]];
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/helpers/cloud_helper.rb b/sonar-server/src/main/webapp/WEB-INF/app/helpers/cloud_helper.rb
new file mode 100644
index 00000000000..8d21be8cbbd
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/helpers/cloud_helper.rb
@@ -0,0 +1,33 @@
+#
+# Sonar, entreprise quality control tool.
+# Copyright (C) 2008-2011 SonarSource
+# mailto:contact AT sonarsource DOT com
+#
+# Sonar 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.
+#
+# Sonar 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 Sonar; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+#
+module CloudHelper
+ MIN_SIZE_PERCENT=60.0
+ MAX_SIZE_PERCENT=240.0
+
+ def font_size(value)
+ divisor=@max_size_value - @min_size_value
+ size=MIN_SIZE_PERCENT
+ if divisor!=0.0
+ multiplier=(MAX_SIZE_PERCENT - MIN_SIZE_PERCENT)/divisor
+ size=MIN_SIZE_PERCENT + ((@max_size_value - (@max_size_value-(value - @min_size_value)))*multiplier)
+ end
+ size.to_i
+ end
+end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_change.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_change.rb
index b58f811538e..218183b7839 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_change.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/active_rule_change.rb
@@ -24,8 +24,8 @@ class ActiveRuleChange < ActiveRecord::Base
def action_text
case enabled
- when true then "enabled"
- when false then "disabled"
+ when true then "on"
+ when false then "off"
when nil then "modified"
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_color.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_color.rb
index 390dc6bb581..745fb54a45b 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/measure_color.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/measure_color.rb
@@ -44,7 +44,7 @@ class MeasureColor
percent = value_to_percent(value, min_value, max_value)
end
else
- if !measure.alert_status.blank? && (options[:check_alert_status]||true)
+ if (options[:check_alert_status]||true) && !measure.alert_status.blank?
case(measure.alert_status)
when Metric::TYPE_LEVEL_OK : percent=100.0
when Metric::TYPE_LEVEL_ERROR : percent=0.0
@@ -61,12 +61,15 @@ class MeasureColor
end
end
+ max_color=options[:max_color]||MAX_COLOR
+ min_color=options[:min_color]||MIN_COLOR
+ mean_color=options[:mean_color]||MEAN_COLOR
if percent<0.0
NONE_COLOR
elsif (percent > 50.0)
- MAX_COLOR.mix_with(MEAN_COLOR, (percent - 50.0) * 2.0)
+ max_color.mix_with(mean_color, (percent - 50.0) * 2.0)
else
- MIN_COLOR.mix_with(MEAN_COLOR, (50.0 - percent) * 2.0)
+ min_color.mix_with(mean_color, (50.0 - percent) * 2.0)
end
end
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb
index e44ce280a55..638270e1476 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/models/review.rb
@@ -261,7 +261,7 @@ class Review < ActiveRecord::Base
xml.comments do
review_comments.each do |comment|
xml.comment do
- xml.id(comment.id)
+ xml.id(comment.id.to_i)
xml.author(comment.user.login)
xml.updatedAt(Api::Utils.format_datetime(comment.updated_at))
if convert_markdown
@@ -296,7 +296,7 @@ class Review < ActiveRecord::Base
comments = []
review_comments.each do |comment|
comments << {
- 'id' => comment.id,
+ 'id' => comment.id.to_i,
'author' => comment.user.login,
'updatedAt' => Api::Utils.format_datetime(comment.updated_at),
'text' => convert_markdown ? comment.html_text : comment.plain_text
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb
new file mode 100644
index 00000000000..2201de2c81b
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/cloud/index.html.erb
@@ -0,0 +1,63 @@
+<style>
+ #cloud a {
+ text-decoration: none;
+ }
+</style>
+<script type="text/javascript">
+ // open view
+ function ov(id) {
+ window.location.href = '<%=ApplicationController.root_context-%>/cloud/index/' + id + '?size=<%= @size_metric.key -%>&color=<%= @color_metric.key -%>';
+ return false;
+ }
+
+ // open file
+ function of(id) {
+ window.open('<%=ApplicationController.root_context-%>/resource/index/' + id + '?metric=<%= @color_metric.key -%>', 'resource', 'height=800,width=900,scrollbars=1,resizable=1');
+ return false;
+ }
+</script>
+
+<form id="cloudform" action="<%= ApplicationController.root_context -%>/cloud/index/<%= @project.id -%>" method="GET">
+ <ul class="headerLine">
+ <li class="first">
+ <span class="note">Color:</span>
+ <select name="color" onchange="document.forms['cloudform'].submit()">
+ <option value="coverage" <%= 'selected' if @color_metric.key=='coverage' -%>>Coverage</option>
+ <option value="violations_density" <%= 'selected' if @color_metric.key=='violations_density' -%>>Rules compliance</option>
+ </select>
+ </li>
+ <li>
+ <input type="radio" name="size" value="ncloc" <%= 'checked' if @size_metric.key=='ncloc' -%> onchange="document.forms['cloudform'].submit()">
+ Quick wins</option>
+ &nbsp;
+ <input type="radio" name="size" value="function_complexity" <%= 'checked' if @size_metric.key=='function_complexity' -%> onchange="document.forms['cloudform'].submit()">
+ Top risk</input>
+ </li>
+ </ul>
+</form>
+
+<div id="cloud">
+ <%
+ color_options={
+ :check_alert_status => false,
+ :min_color => Color::RGB.from_html("EE0000"), # red
+ :mean_color => Color::RGB.from_html("4D05B1"), # purple
+ :max_color => Color::RGB.from_html("2360BF")} # blue
+ @snapshots.each do |s|
+ size_measure=@size_measure_by_sid[s.id]
+ if size_measure && size_measure.value
+ color_measure=@color_measure_by_sid[s.id]
+ if s.resource.copy_resource_id
+ link="ov(#{s.resource.copy_resource_id})"
+ else
+ link="of(#{s.project_id})"
+ end
+ title="#{s.resource.long_name} | #{@size_metric.short_name}: #{size_measure.formatted_value}"
+ if color_measure && color_measure.value
+ title += " | #{@color_metric.short_name}: #{color_measure.formatted_value}"
+ end
+ %>
+ <a href="#" onclick="<%= link -%>" title="<%= title -%>"><span style="font-size:<%= font_size(size_measure.value) -%>%;color: <%= MeasureColor.color(color_measure, color_options).html -%>"><%= s.resource.name %></span></a>
+ <% end
+ end %>
+</div> \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
index e6ab11b5d22..7de0d6da97e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/layouts/_layout.html.erb
@@ -41,6 +41,7 @@
<li class="<%= 'selected' if request.request_uri.include?('/components/index') -%>"><a href="<%= ApplicationController.root_context -%>/components/index/<%= @project.id -%>">Components</a></li>
<li class="<%= 'selected' if request.request_uri.include?('/drilldown/violations') -%>"><a href="<%= ApplicationController.root_context -%>/drilldown/violations/<%= @project.id -%>">Violations drilldown</a></li>
<li class="<%= 'selected' if controller.controller_path=='timemachine' -%>"><a href="<%= ApplicationController.root_context -%>/timemachine/index/<%= @project.id -%>">Time machine</a></li>
+ <li class="<%= 'selected' if request.request_uri.include?('/cloud/index') -%>"><a href="<%= ApplicationController.root_context -%>/cloud/index/<%= @project.id -%>">Clouds</a></li>
<% controller.java_facade.getPages(Navigation::SECTION_RESOURCE, @project.scope, @project.qualifier, @project.language).each do |page| %>
<li class="<%= 'selected' if request.request_uri.include?("page=#{page.getId()}") -%>"><a href="<%= ApplicationController.root_context -%>/plugins/resource/<%= @project.id-%>?page=<%= page.getId() -%>"><%= page.getTitle() %></a></li>
<% end %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb
index d1cfc1635c4..049de5a9a8d 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/changelog.html.erb
@@ -8,9 +8,9 @@
<% form_tag({:action => 'changelog'}, {:method => 'post'}) do %>
<%= hidden_field_tag "id", @profile.id %>
- Cahngelog between
+ Changelog from
<%= select_tag "since", options_for_select(@select_versions, @since_version) %>
- and
+ to
<%= select_tag "to", options_for_select(@select_versions, @to_version) %>
<%= submit_tag "Load", :id => 'submit'%>
<% end %>
@@ -31,10 +31,10 @@
%>
<tr class="<%= cycle('even', 'odd') -%>">
<td valign="top"><%= change.profile_version - 1 %> -> <%= change.profile_version %></td>
- <td valign="top"><%=change.change_date.strftime("%Y-%m-%d %H:%M:%S")%></td>
- <td valign="top"><%=change.user_name%></td>
- <td valign="top"><%=change.action_text%></td>
- <td valign="top"><%=change.rule.name%></td>
+ <td valign="top"><%= l(change.change_date) -%></td>
+ <td valign="top"><%= change.user_name %></td>
+ <td valign="top"><%= change.action_text %></td>
+ <td valign="top"><%= change.rule.name %></td>
<td valign="top">
<% if change.old_severity
if change.new_severity %>
diff --git a/sonar-server/src/main/webapp/WEB-INF/config/locales/de.yml b/sonar-server/src/main/webapp/WEB-INF/config/locales/de.yml
new file mode 100644
index 00000000000..472666079e6
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/config/locales/de.yml
@@ -0,0 +1,10 @@
+# Override default date formats
+
+de:
+ date:
+ formats:
+ default: "%d. %b %Y"
+
+ time:
+ formats:
+ default: "%d. %b %Y %H:%M" \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/WEB-INF/config/locales/en.yml b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-AU.yml
index f164a55f98e..9b4fd514388 100644
--- a/sonar-server/src/main/webapp/WEB-INF/config/locales/en.yml
+++ b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-AU.yml
@@ -1,6 +1,6 @@
# Override default locale
-en:
+"en-AU":
date:
formats:
default: "%d %b %Y"
diff --git a/sonar-server/src/main/webapp/WEB-INF/config/locales/en-GB.yml b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-GB.yml
new file mode 100644
index 00000000000..0ef3ab82836
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-GB.yml
@@ -0,0 +1,13 @@
+# Override default locale
+
+"en-GB":
+ date:
+ formats:
+ default: "%d %b %Y"
+
+ time:
+ formats:
+ default: "%d %b %Y %H:%M"
+ am: "am"
+ pm: "pm"
+
diff --git a/sonar-server/src/main/webapp/WEB-INF/config/locales/en-US.yml b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-US.yml
new file mode 100644
index 00000000000..154c872dc28
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/config/locales/en-US.yml
@@ -0,0 +1,13 @@
+# Override default locale
+
+"en-US":
+ date:
+ formats:
+ default: "%d %b %Y"
+
+ time:
+ formats:
+ default: "%d %b %Y %H:%M"
+ am: "am"
+ pm: "pm"
+
diff --git a/sonar-server/src/main/webapp/stylesheets/style.css b/sonar-server/src/main/webapp/stylesheets/style.css
index f0246a34b58..f43efd4d03f 100644
--- a/sonar-server/src/main/webapp/stylesheets/style.css
+++ b/sonar-server/src/main/webapp/stylesheets/style.css
@@ -1178,6 +1178,24 @@ table.header1 td {
text-align: left;
vertical-align: top;
}
+.headerLine {
+ background-color: #ECECEC;
+ color: #444;
+ border: 1px solid #DDD;
+ margin: 0 0 10px 0;
+ line-height: 30px;
+ height: 30px;
+ width: 100%;
+}
+ul.headerLine li {
+ float: left;
+ display: block;
+ padding: 0 10px 0;
+ background: url("../images/sep12.png") no-repeat scroll 0 50% transparent;
+}
+ul.headerLine li.first {
+ background: none;
+}
select.withIcons option {
background-repeat: no-repeat;
background-position: 2px 0;
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java
index 596b2763639..646e2b2a7a1 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Review.java
@@ -143,6 +143,7 @@ public class Review extends Model {
* @deprecated since 2.9. Use {@link #getFalsePositive()} instead.
* @return the type
*/
+ @Deprecated
public String getType() {
return type;
}
@@ -152,6 +153,7 @@ public class Review extends Model {
* @param s
* the type to set
*/
+ @Deprecated
public Review setType(String s) {
this.type = s;
// the following code is only here to ensure backward compatibility with 2.8
@@ -244,7 +246,7 @@ public class Review extends Model {
this.falsePositive = falsePositive;
return this;
}
-
+
/**
* @since 2.9
* @return the violation id
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java
index d1858cd242f..07cc0da834e 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ReviewQuery.java
@@ -29,6 +29,9 @@ public class ReviewQuery extends Query<Review> {
public static final String OUTPUT_PLAIN = "PLAIN";
public static final String OUTPUT_HTML = "HTML";
+ /**
+ * @deprecated since 2.9, but kept for backward compatibility
+ */
@Deprecated
private String reviewType;
private Long id;
@@ -49,6 +52,7 @@ public class ReviewQuery extends Query<Review> {
* @deprecated since 2.9
* @return NULL
*/
+ @Deprecated
public String getReviewType() {
return reviewType;
}
@@ -58,6 +62,7 @@ public class ReviewQuery extends Query<Review> {
* @param reviewType
* the reviewType to set
*/
+ @Deprecated
public ReviewQuery setReviewType(String reviewType) {
this.reviewType = reviewType;
return this;