diff options
author | Fabrice Bellingard <bellingard@gmail.com> | 2011-05-05 15:10:57 +0200 |
---|---|---|
committer | Fabrice Bellingard <bellingard@gmail.com> | 2011-05-05 15:10:57 +0200 |
commit | c72a3de1c77a89ec1671233cfd5debbf50881ff6 (patch) | |
tree | 27882d21096cd61375d85885d1cc1577d06663e5 | |
parent | 1f6a6958150484a5a0dc766b4d794f6ae4bb839a (diff) | |
parent | bcc445118956633eb4084581a47edbe5672cefb4 (diff) | |
download | sonarqube-c72a3de1c77a89ec1671233cfd5debbf50881ff6.tar.gz sonarqube-c72a3de1c77a89ec1671233cfd5debbf50881ff6.zip |
Merge remote branch 'upstream/master'
35 files changed, 124 insertions, 952 deletions
diff --git a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSensor.java b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSensor.java index 3b2311e0f1f..83eb1b544fa 100644 --- a/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSensor.java +++ b/plugins/sonar-checkstyle-plugin/src/main/java/org/sonar/plugins/checkstyle/CheckstyleSensor.java @@ -23,7 +23,6 @@ import org.sonar.api.batch.Sensor; import org.sonar.api.batch.SensorContext; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Project; -import org.sonar.api.utils.Logs; public class CheckstyleSensor implements Sensor { diff --git a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java index c4e24332fe2..70a6a843780 100644 --- a/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java +++ b/plugins/sonar-cobertura-plugin/src/main/java/org/sonar/plugins/cobertura/api/CoberturaUtils.java @@ -39,6 +39,7 @@ public final class CoberturaUtils { * @deprecated in 2.8, because assumes that Sonar executed from Maven. Not used any more in sonar-cobertura-plugin. * See http://jira.codehaus.org/browse/SONAR-2321 */ + @Deprecated public static File getReport(Project project) { File report = getReportFromProperty(project); if (report == null) { diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java index ece114c8144..4935390e21d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java @@ -23,7 +23,9 @@ import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import org.apache.commons.codec.digest.DigestUtils; +import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang.math.NumberUtils; import org.sonar.api.batch.*; import org.sonar.api.database.model.RuleFailureModel; import org.sonar.api.database.model.SnapshotSource; @@ -123,7 +125,7 @@ public class ViolationPersisterDecorator implements Decorator { return violationMap; } - private final boolean isNotAlreadyMapped(Violation newViolation, Map<Violation, RuleFailureModel> violationMap) { + private boolean isNotAlreadyMapped(Violation newViolation, Map<Violation, RuleFailureModel> violationMap) { return violationMap.get(newViolation) == null; } @@ -161,7 +163,10 @@ public class ViolationPersisterDecorator implements Decorator { } private boolean isSameLine(Violation newViolation, RuleFailureModel pastViolation) { - return pastViolation.getLine() == newViolation.getLineId(); //When lines are null, we also return true + if (pastViolation.getLine()==null && newViolation.getLineId()==null) { + return true; + } + return ObjectUtils.equals(pastViolation.getLine(), newViolation.getLineId()); } private boolean isSameMessage(Violation newViolation, RuleFailureModel pastViolation) { diff --git a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java index 7a5b86c0830..5a62645666f 100644 --- a/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java +++ b/plugins/sonar-findbugs-plugin/src/main/java/org/sonar/plugins/findbugs/FindbugsSensor.java @@ -19,7 +19,6 @@ */ package org.sonar.plugins.findbugs; -import org.apache.commons.lang.StringUtils; import org.sonar.api.CoreProperties; import org.sonar.api.batch.Sensor; import org.sonar.api.batch.SensorContext; diff --git a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdSensor.java b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdSensor.java index 079be40e4f3..8be261318ba 100644 --- a/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdSensor.java +++ b/plugins/sonar-pmd-plugin/src/main/java/org/sonar/plugins/pmd/PmdSensor.java @@ -19,16 +19,15 @@ */ package org.sonar.plugins.pmd; -import java.io.File; - import org.sonar.api.batch.Sensor; import org.sonar.api.batch.SensorContext; import org.sonar.api.profiles.RulesProfile; import org.sonar.api.resources.Project; import org.sonar.api.rules.RuleFinder; -import org.sonar.api.utils.Logs; import org.sonar.api.utils.XmlParserException; +import java.io.File; + public class PmdSensor implements Sensor { private RulesProfile profile; diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/EmptyFileCheck.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/EmptyFileCheck.java index 40e276d4d13..9377f080c6a 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/EmptyFileCheck.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/squid/check/EmptyFileCheck.java @@ -22,9 +22,7 @@ package org.sonar.java.squid.check; import org.sonar.check.Priority; import org.sonar.check.Rule; -import org.sonar.check.RuleProperty; import org.sonar.squid.api.CheckMessage; -import org.sonar.squid.api.SourceClass; import org.sonar.squid.api.SourceFile; import org.sonar.squid.measures.Metric; @@ -35,7 +33,7 @@ public final class EmptyFileCheck extends SquidCheck { @Override public void visitFile(SourceFile file) { int loc = file.getInt(Metric.LINES_OF_CODE); - if (loc==0) { + if (loc == 0) { CheckMessage message = new CheckMessage(this, "This Java file is empty"); file.log(message); } diff --git a/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefirePlugin.java b/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefirePlugin.java index 27f9abe2d8e..1cefa95d4e9 100644 --- a/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefirePlugin.java +++ b/plugins/sonar-surefire-plugin/src/main/java/org/sonar/plugins/surefire/SurefirePlugin.java @@ -19,9 +19,11 @@ */ package org.sonar.plugins.surefire; -import org.sonar.api.*; +import org.sonar.api.CoreProperties; +import org.sonar.api.Properties; +import org.sonar.api.Property; +import org.sonar.api.SonarPlugin; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; diff --git a/sonar-channel/src/main/java/org/sonar/channel/RegexChannel.java b/sonar-channel/src/main/java/org/sonar/channel/RegexChannel.java index cf44de7f3a8..f453522d427 100644 --- a/sonar-channel/src/main/java/org/sonar/channel/RegexChannel.java +++ b/sonar-channel/src/main/java/org/sonar/channel/RegexChannel.java @@ -52,7 +52,7 @@ public abstract class RegexChannel<OUTPUT> extends Channel<OUTPUT> { } return false; } catch (StackOverflowError e) { - throw new RuntimeException( + throw new IllegalArgumentException( "The regular expression " + regex + " has led to a stack overflow error. " diff --git a/sonar-markdown/src/main/java/org/sonar/markdown/HtmlListChannel.java b/sonar-markdown/src/main/java/org/sonar/markdown/HtmlListChannel.java index 0f71e4cda31..956bd1978e5 100644 --- a/sonar-markdown/src/main/java/org/sonar/markdown/HtmlListChannel.java +++ b/sonar-markdown/src/main/java/org/sonar/markdown/HtmlListChannel.java @@ -34,6 +34,7 @@ class HtmlListChannel extends Channel<MarkdownOutput> { try { if (code.getColumnPosition() == 0 && listElement.consume(code, output)) { while (endOfLine.consume(code, output) && listElement.consume(code, output)) { + // consume input } output.append("</ul>"); return true; @@ -52,7 +53,7 @@ class HtmlListChannel extends Channel<MarkdownOutput> { @Override protected void consume(CharSequence token, MarkdownOutput output) { - if ( !pendingListConstruction) { + if (!pendingListConstruction) { output.append("<ul>"); pendingListConstruction = true; } @@ -75,7 +76,7 @@ class HtmlListChannel extends Channel<MarkdownOutput> { } } - private class EndOfLine extends RegexChannel<MarkdownOutput> { + private static final class EndOfLine extends RegexChannel<MarkdownOutput> { public EndOfLine() { super("(\r?\n)|(\r)"); diff --git a/sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java b/sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java index 73c639e8182..13c80ce39ff 100644 --- a/sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java +++ b/sonar-markdown/src/main/java/org/sonar/markdown/MarkdownEngine.java @@ -19,37 +19,45 @@ */ package org.sonar.markdown; -import java.util.ArrayList; -import java.util.List; - import org.sonar.channel.Channel; import org.sonar.channel.ChannelDispatcher; import org.sonar.channel.CodeReader; +import java.util.Arrays; +import java.util.List; + /** * Entry point of the Markdown library */ -public class MarkdownEngine { +public final class MarkdownEngine { - private MarkdownOutput output; private ChannelDispatcher<MarkdownOutput> dispatcher; private MarkdownEngine() { - output = new MarkdownOutput(); - List<Channel> markdownChannels = new ArrayList<Channel>(); - markdownChannels.add(new HtmlUrlChannel()); - markdownChannels.add(new HtmlEndOfLineChannel()); - markdownChannels.add(new HtmlEmphasisChannel()); - markdownChannels.add(new HtmlListChannel()); - markdownChannels.add(new HtmlCodeChannel()); - markdownChannels.add(new IdentifierAndNumberChannel()); - markdownChannels.add(new BlackholeChannel()); + List<Channel> markdownChannels = Arrays.<Channel>asList( + new HtmlUrlChannel(), + new HtmlEndOfLineChannel(), + new HtmlEmphasisChannel(), + new HtmlListChannel(), + new HtmlCodeChannel(), + new IdentifierAndNumberChannel(), + new BlackholeChannel()); dispatcher = new ChannelDispatcher<MarkdownOutput>(markdownChannels); } + private String convert(String input) { + CodeReader reader = new CodeReader(input); + try { + MarkdownOutput output = new MarkdownOutput(); + dispatcher.consume(reader, output); + return output.toString(); + + } finally { + reader.close(); + } + } + public static String convertToHtml(String input) { - MarkdownEngine engine = new MarkdownEngine(); - engine.dispatcher.consume(new CodeReader(input), engine.output); - return engine.output.toString(); + return new MarkdownEngine().convert(input); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java b/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java index 092489ec08f..b69bc0cea6f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/Plugin.java @@ -31,6 +31,7 @@ import java.util.List; * @since 1.10 * @deprecated in 2.8. Use {@link SonarPlugin} instead. */ +@Deprecated public interface Plugin { /** diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java index 57103c691d0..2a737ad13ad 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java @@ -109,7 +109,7 @@ public interface DecoratorContext { * the request parameters specified as a {@link ViolationQuery} * @return the list of violations that match those parameters */ - public abstract List<Violation> getViolations(ViolationQuery violationQuery); + abstract List<Violation> getViolations(ViolationQuery violationQuery); /** * Returns all the active (= non switched-off) violations found on the current resource. diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/AbstractViewer.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/AbstractViewer.java deleted file mode 100644 index 1fbc0c8422a..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/AbstractViewer.java +++ /dev/null @@ -1,216 +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.JavaScriptObject; -import com.google.gwt.user.client.ui.FlowPanel; -import com.google.gwt.user.client.ui.Panel; -import com.google.gwt.user.client.ui.RootPanel; -import com.google.gwt.user.client.ui.Widget; -import org.sonar.api.web.gwt.client.webservices.*; - -import java.util.Arrays; - -public abstract class AbstractViewer implements EntryPoint { - - public static final String HTML_ROOT_ID = "resource_viewers"; - - private Resource resource; - private String renderedResourceKey = ""; - private Panel widgetPanel = null; - private boolean standAloneMode = true; - - public void onModuleLoad() { - exportJavascript(); - } - - /** - * Export GWT javascript methods to load and control the plugin, must export currently 2 method : - * I.E for plugin GWT id : foo.bar.MyPlugin, class foo.bar.client.MyPlugin : - * <p/> - * $wnd.load_foo_bar_MyPlugin = function() { - * called to the plugin init from JS - * obj.@foo.bar.client.MyPlugin::loadContainer()(); - * } - * $wnd.on_resource_loaded_foo_bar_MyPlugin = function() { - * called when a resource JSON object has been refreshed within the page - * obj.@foo.bar.client.MyPlugin::onResourceLoaded()(); - * } - */ - protected abstract void exportJavascript(); - - /** - * When multiple widgets are bound to the same HTML div, this method will indicate - * If the resource widget is the default one to show when the widget is initialized - * - * @param metric the metric for which the widget is shown, cannot be null - * @param resource the resource bound to the widget - * @return true or false - */ - protected abstract boolean isDefault(WSMetrics.Metric metric, Resource resource); - - /** - * Finds if a given metric is in the provided metrics list - * - * @param metric the metric to search - * @param metricsList the metric list - * @return true or false if not found - */ - protected boolean isMetricInList(WSMetrics.Metric metric, WSMetrics.Metric... metricsList) { - return Arrays.asList(metricsList).contains(metric); - } - - /** - * When multiple widgets are in the same page, this method will indicate if the widget - * can be shown for the given resource - * - * @param resource the resource bound to the page - * @return true or false - */ - protected abstract boolean isForResource(Resource resource); - - - public Resource getResource() { - return resource; - } - - private Resource loadResource() { - JavaScriptObject resourceJson = getResourceJSONObject(); - if (resourceJson != null) { - Resource resourceLoaded = ResourcesQuery.parseResources(resourceJson).get(0); - String currentMetricKey = ResourceDictionary.getViewerMetricKey(); - Boolean isDefaultForMetric = false; - if (currentMetricKey != null) { - isDefaultForMetric = isDefault(WSMetrics.get(currentMetricKey), resourceLoaded); - } - exportJSBooleanVariable("is_default_for_metric", Utils.widgetGWTIdJSEncode(getGwtId()), isDefaultForMetric); - exportJSBooleanVariable("is_for_resource", Utils.widgetGWTIdJSEncode(getGwtId()), isForResource(resourceLoaded)); - return resourceLoaded; - } - return null; - } - - /** - * Called when a resource JSON object has been loaded within the page - */ - public final void onResourceLoaded() { - resource = loadResource(); - standAloneMode = false; - } - - /** - * Called to render the widget for the given resource object loaded via the onResourceLoaded() method call - */ - public final void loadContainer() { - String resourceKey = ResourceDictionary.getViewerResourceKey(); - if (resourceKey != null) { - if (!standAloneMode && resource == null) { - Utils.showError("Unable to find JSON resource object, unable to render widget"); - return; - } else if (standAloneMode && resource == null) { - getResourceJsonObject(resourceKey); - return; - } - String currentResourceKey = isANumber(resourceKey) ? resource.getId().toString() : resource.getKey(); - if (!renderedResourceKey.equals(currentResourceKey)) { - // resource key has changed reload if not in standalone mode - if (!standAloneMode) { - resource = loadResource(); - } - - if (widgetPanel == null) { - RootPanel rootPanel = RootPanel.get(HTML_ROOT_ID); - if (rootPanel == null) { - Utils.showError("Unable to find root panel " + HTML_ROOT_ID + " in page"); - } - widgetPanel = new FlowPanel(); - widgetPanel.setStyleName("gwt-ResourceTab"); - String panelId = "tab-" + Utils.widgetGWTIdJSEncode(getGwtId()); - widgetPanel.getElement().setId(panelId); - registerTab(panelId); - widgetPanel.setVisible(false); - rootPanel.add(widgetPanel); - } - - renderedResourceKey = resourceKey; - - if (widgetPanel != null) { - widgetPanel.clear(); - widgetPanel.add(render(resource)); - } - } - } - - if (widgetPanel != null) { - widgetPanel.setVisible(true); - } - } - - private static native void registerTab(Object tabId) /*-{ - $wnd.registeredTabs.push(tabId); - }-*/; - - - private native void exportJSBooleanVariable(String varPrefix, String encodedGWTId, boolean value)/*-{ - $wnd.config[varPrefix + "_" + encodedGWTId] = value; - }-*/; - - /** - * Return the GWT id of the widget - */ - protected abstract String getGwtId(); - - /** - * Renders the widget for the current resource - */ - protected abstract Widget render(Resource resource); - - /** - * Return a JavaScriptObject object containing all the measure available for the current resource key - * - * @return the JavaScriptObject instance, should never be null - */ - protected native JavaScriptObject getResourceJSONObject()/*-{ - return $wnd.config['current_resource']; - }-*/; - - - private boolean isANumber(String resourceKey) { - boolean isIdResourceKey = true; - try { - Integer.parseInt(resourceKey); - } catch (NumberFormatException ex) { - isIdResourceKey = false; - } - return isIdResourceKey; - } - - private void getResourceJsonObject(String resourceKey) { - ResourcesQuery.get(resourceKey).execute(new StandAloneResourceHandler()); - } - - public class StandAloneResourceHandler extends BaseQueryCallback<Resources> { - public void onResponse(Resources resources, JavaScriptObject jsonResponse) { - resource = resources.firstResource(); - loadContainer(); - } - } -} 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 index 2453e5646e9..ea08ac8c8dd 100644 --- 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 @@ -21,6 +21,10 @@ 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"; 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 index 4c19d9cd61c..97f6b9d6a8f 100644 --- 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 @@ -32,7 +32,9 @@ 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() { } 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 index ba17c5ea0a8..bd997d099b9 100644 --- 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 @@ -22,6 +22,10 @@ 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; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/FileSource.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/FileSource.java deleted file mode 100644 index db4a15414c3..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/FileSource.java +++ /dev/null @@ -1,41 +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.Map; - -/** - * @deprecated since 2.5, use {@link org.sonar.wsclient.services.Source} instead. - */ -@Deprecated -public class FileSource extends ResponsePOJO { - - private Map<Integer, String> sourceLines; - - public FileSource(Map<Integer, String> sourceLines) { - super(); - this.sourceLines = sourceLines; - } - - public Map<Integer, String> getLines() { - return sourceLines; - } - -} 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 index 4f5fa9cf9bd..0ff29c002dc 100644 --- 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 @@ -21,6 +21,10 @@ 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; 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 index 2ed28c9ff68..a2d6552a254 100644 --- 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 @@ -32,6 +32,10 @@ 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; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Properties.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Properties.java deleted file mode 100644 index 792ca98c957..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Properties.java +++ /dev/null @@ -1,48 +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 Properties extends ResponsePOJO { - - private List<Property> properties; - - public Properties(List<Property> properties) { - this.properties = properties; - } - - public List<Property> getProperties() { - return properties; - } - - public String get(String key, String defaultValue) { - for (Property property : properties) { - if (property.getKey().equals(key)) { - return property.getValue(); - } - } - return defaultValue; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/PropertiesQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/PropertiesQuery.java deleted file mode 100644 index 4526bbe7455..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/PropertiesQuery.java +++ /dev/null @@ -1,79 +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 java.util.ArrayList; -import java.util.List; - -/** - * @deprecated since 2.5, use {@link org.sonar.wsclient.services.PropertyQuery} instead. - */ -@Deprecated -public final class PropertiesQuery extends Query<Properties> { - - private String key; - - public PropertiesQuery() { - } - - public PropertiesQuery(String key) { - this.key = key; - } - - @Override - public String toString() { - String url = Utils.getServerApiUrl() + "/properties"; - if (key != null) { - url += "/" + key; - } - return url + "?"; - } - - @Override - public void execute(QueryCallBack<Properties> callback) { - JsonUtils.requestJson(this.toString(), new JSONHandlerDispatcher<Properties>(callback) { - @Override - public Properties parseResponse(JavaScriptObject obj) { - return new Properties(parseProperties(obj)); - } - - private List<Property> parseProperties(JavaScriptObject obj) { - JSONArray array = new JSONArray(obj); - List<Property> properties = new ArrayList<Property>(); - for (int i = 0; i < array.size(); i++) { - JSONObject jsonObject = array.get(i).isObject(); - if (jsonObject != null) { - properties.add(parseProperty(jsonObject)); - } - } - return properties; - } - - private Property parseProperty(JSONObject json) { - return new Property(JsonUtils.getString(json, "key"), JsonUtils.getString(json, "value")); - } - }); - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Property.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Property.java deleted file mode 100644 index e29d8ea4f83..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Property.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; - -/** - * @deprecated since 2.5, use {@link org.sonar.wsclient.services.Property} instead - */ -@Deprecated -public class Property extends ResponsePOJO { - - private String key; - private String value; - - public Property() { - } - - public Property(String key, String value) { - this.key = key; - this.value = value; - } - - public String getKey() { - return key; - } - - public Property setKey(String key) { - this.key = key; - return this; - } - - public String getValue() { - return value; - } - - public Property setValue(String value) { - this.value = value; - return this; - } -} 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 index 1509665b08b..7bbfacc2a2c 100644 --- 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 @@ -19,6 +19,10 @@ */ 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 index f0d433a8815..4f441b2be5b 100644 --- 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 @@ -21,6 +21,10 @@ 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); 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 index 2f2e6abb335..6a54fffb941 100644 --- 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 @@ -22,6 +22,10 @@ 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/SequentialQueries.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SequentialQueries.java index ebbcd3926d5..55301f41367 100644 --- 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 @@ -25,6 +25,10 @@ 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<?>>(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SourcesQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SourcesQuery.java deleted file mode 100644 index fc60936362e..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/SourcesQuery.java +++ /dev/null @@ -1,107 +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.Map; -import java.util.TreeMap; - -/** - * @deprecated since 2.5, use {@link org.sonar.wsclient.services.SourceQuery} instead - */ -@Deprecated -public final class SourcesQuery extends AbstractResourceQuery<FileSource> { - - private Integer from; - private Integer length; - private boolean color; - - public static SourcesQuery get(String resourceKey) { - return new SourcesQuery(resourceKey); - } - - private SourcesQuery(String resourceKey) { - super(resourceKey); - } - - public SourcesQuery setFrom(Integer from) { - this.from = from; - return this; - } - - public SourcesQuery setLength(Integer length) { - this.length = length; - return this; - } - - public SourcesQuery setColor(boolean color) { - this.color = color; - return this; - } - - @Override - public String toString() { - String url = Utils.getServerApiUrl() + "/sources?resource=" + getResourceKey() + "&"; - if (length > 0) { - url += "from=" + from + "&to=" + (from + length) + "&"; - } - if (color) { - url += "color=true&"; - } - return url; - } - - @Override - public void execute(QueryCallBack<FileSource> callback) { - JsonUtils.requestJson(this.toString(), new JSONHandlerDispatcher<FileSource>(callback) { - @Override - public FileSource parseResponse(JavaScriptObject obj) { - return parseLines(obj); - } - }); - } - - private FileSource parseLines(JavaScriptObject obj) { - Map<Integer, String> sourceLines = new TreeMap<Integer, String>(); - FileSource src = new FileSource(sourceLines); - JSONArray jsonArray = new JSONArray(obj); - if (jsonArray.size() == 0) - return src; - JSONObject sources = jsonArray.get(0).isObject(); - if (sources.size() == 0) - return src; - int maxSize = new Double(Math.pow(2, 16)).intValue(); - int currentLine = from == 0 ? 1 : from; - while (currentLine < maxSize) { - JSONValue line = sources.get(Integer.toString(currentLine)); - if (line == null) { - break; - } - sourceLines.put(currentLine++, line.isString().stringValue()); - } - return src; - } - -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Violation.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Violation.java deleted file mode 100644 index 9e522d2b028..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Violation.java +++ /dev/null @@ -1,84 +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, use {@link org.sonar.wsclient.services.Violation} instead. - */ -@Deprecated -public class Violation { - - private String message; - private String priority; - private int line; - private Rule rule; - private Resource resource; - - public Violation(String message, String priority, int line, Rule rule, Resource resource) { - this.message = message; - this.priority = priority; - this.line = line; - this.rule = rule; - this.resource = resource; - } - - public Violation() { - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public String getPriority() { - return priority; - } - - public void setPriority(String priority) { - this.priority = priority; - } - - public int getLine() { - return line; - } - - public void setLine(int line) { - this.line = line; - } - - public Rule getRule() { - return rule; - } - - public void setRule(Rule rule) { - this.rule = rule; - } - - public Resource getResource() { - return resource; - } - - public void setResource(Resource resource) { - this.resource = resource; - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Violations.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Violations.java deleted file mode 100644 index 7cd70b466cd..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/Violations.java +++ /dev/null @@ -1,91 +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.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @deprecated since 2.5 - */ -@Deprecated -public class Violations extends ResponsePOJO { - private List<Violation> violations; - private Map<Integer, List<Violation>> byLines; - - public Violations(List<Violation> violations) { - this.violations = violations; - } - - public Violations() { - this.violations = new ArrayList<Violation>(); - } - - public void add(Violation v) { - violations.add(v); - byLines = null; - } - - public List<Violation> getAll() { - return violations; - } - - public Map<Integer, List<Violation>> getByLines() { - if (byLines == null) { - byLines = new HashMap<Integer, List<Violation>>(); - for (Violation violation : violations) { - List<Violation> lineViolations = byLines.get(violation.getLine()); - if (lineViolations == null) { - lineViolations = new ArrayList<Violation>(); - byLines.put(violation.getLine(), lineViolations); - } - lineViolations.add(violation); - } - } - return byLines; - } - - public String getLevelForLine(Integer line) { - List<Violation> lineViolations = getByLines().get(line); - String level = ""; - if (lineViolations != null) { - for (Violation lineViolation : lineViolations) { - if ("BLOCKER".equals(lineViolation.getPriority()) || "CRITICAL".equals(lineViolation.getPriority()) - || "MAJOR".equals(lineViolation.getPriority())) { - level = "error"; - - } else if (!"error".equals(level)) { - level = "warning"; - } - } - } - return level; - } - - public int countForLine(Integer line) { - List<Violation> lineViolations = getByLines().get(line); - if (lineViolations == null) { - return 0; - } - return lineViolations.size(); - } -} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ViolationsQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ViolationsQuery.java deleted file mode 100644 index ef699338d27..00000000000 --- a/sonar-plugin-api/src/main/java/org/sonar/api/web/gwt/client/webservices/ViolationsQuery.java +++ /dev/null @@ -1,167 +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.JSONString; -import com.google.gwt.json.client.JSONValue; -import org.sonar.api.web.gwt.client.Utils; - -/** - * @deprecated since 2.5, use {@link org.sonar.wsclient.services.ViolationQuery} instead. - */ -@Deprecated -public final class ViolationsQuery extends AbstractResourceQuery<Violations> { - - private String scopes; - private String qualifiers; - private String rules; - private String priorities; - private Integer depth; - - private ViolationsQuery(String resourceKey) { - super(resourceKey); - } - - public static ViolationsQuery create(String resourceKey) { - return new ViolationsQuery(resourceKey); - } - - public String getScopes() { - return scopes; - } - - public ViolationsQuery setScopes(String scopes) { - this.scopes = scopes; - return this; - } - - public String getQualifiers() { - return qualifiers; - } - - public ViolationsQuery setQualifiers(String qualifiers) { - this.qualifiers = qualifiers; - return this; - } - - public String getRules() { - return rules; - } - - public ViolationsQuery setRules(String rules) { - this.rules = rules; - return this; - } - - /** - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - public String getCategories() { - return null; - } - - /** - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - public ViolationsQuery setCategories(String s) { - return this; - } - - public Integer getDepth() { - return depth; - } - - public ViolationsQuery setDepth(Integer depth) { - this.depth = depth; - return this; - } - - public String getPriorities() { - return priorities; - } - - public ViolationsQuery setPriorities(String priorities) { - this.priorities = priorities; - return this; - } - - @Override - public String toString() { - String url = Utils.getServerApiUrl() + "/violations?resource=" + getResourceKey() + "&"; - if (depth != null) { - url += "depth=" + depth + "&"; - } - if (scopes != null) { - url += "scopes=" + scopes + "&"; - } - if (qualifiers != null) { - url += "qualifiers=" + qualifiers + "&"; - } - if (rules != null) { - url += "rules=" + rules + "&"; - } - if (priorities != null) { - url += "priorities=" + priorities + "&"; - } - return url; - } - - @Override - public void execute(final QueryCallBack<Violations> callback) { - JsonUtils.requestJson(this.toString(), new JSONHandlerDispatcher<Violations>(callback) { - @Override - public Violations parseResponse(JavaScriptObject obj) { - return parseJSON(obj); - } - }); - } - - private Violations parseJSON(JavaScriptObject obj) { - Violations result = new Violations(); - JSONArray jsonArray = new JSONArray(obj); - for (int i = 0; i < jsonArray.size(); i++) { - JSONObject jsViolation = jsonArray.get(i).isObject(); - if (jsViolation == null) { - continue; - } - JSONString message = jsViolation.get("message").isString(); - JSONString priority = jsViolation.get("priority").isString(); - JSONValue lineJson = jsViolation.get("line"); - int lineIndex = 0; - if (lineJson != null) { - lineIndex = (int) lineJson.isNumber().doubleValue(); - } - - JSONObject ruleObj = jsViolation.get("rule").isObject(); - Rule rule = new Rule( - JsonUtils.getString(ruleObj, "key"), - JsonUtils.getString(ruleObj, "name")); - - result.add(new Violation(message.stringValue(), priority.stringValue(), lineIndex, rule, null)); - } - return result; - } - -} 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 index 593254c98bb..6eee34741a2 100644 --- 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 @@ -19,6 +19,10 @@ */ 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 index ee1b5c409f1..5b8ffadd08a 100644 --- 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 @@ -24,6 +24,10 @@ 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() { diff --git a/sonar-server/src/main/java/org/sonar/server/database/CustomHibernateConnectionProvider.java b/sonar-server/src/main/java/org/sonar/server/database/CustomHibernateConnectionProvider.java index 35d83ecce78..695a706c9ae 100644 --- a/sonar-server/src/main/java/org/sonar/server/database/CustomHibernateConnectionProvider.java +++ b/sonar-server/src/main/java/org/sonar/server/database/CustomHibernateConnectionProvider.java @@ -20,7 +20,6 @@ package org.sonar.server.database; -import org.hibernate.HibernateException; import org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider; import javax.sql.DataSource; @@ -31,7 +30,7 @@ public class CustomHibernateConnectionProvider extends InjectedDataSourceConnect static DataSource datasource; @Override - public void configure(Properties props) throws HibernateException { + public void configure(Properties props) { setDataSource(datasource); super.configure(props); } diff --git a/sonar-server/src/main/java/org/sonar/server/database/JndiDatabaseConnector.java b/sonar-server/src/main/java/org/sonar/server/database/JndiDatabaseConnector.java index e78ba0bacc4..fa694867bd7 100644 --- a/sonar-server/src/main/java/org/sonar/server/database/JndiDatabaseConnector.java +++ b/sonar-server/src/main/java/org/sonar/server/database/JndiDatabaseConnector.java @@ -23,7 +23,6 @@ import org.apache.commons.configuration.Configuration; import org.apache.commons.dbcp.BasicDataSourceFactory; import org.apache.commons.lang.StringUtils; import org.hibernate.cfg.Environment; -import org.sonar.api.CoreProperties; import org.sonar.api.database.DatabaseProperties; import org.sonar.api.utils.Logs; import org.sonar.api.utils.SonarException; @@ -92,7 +91,7 @@ public class JndiDatabaseConnector extends AbstractDatabaseConnector { try { Context envCtx = (Context) ctx.lookup(JNDI_ENV_CONTEXT); - datasource = (DataSource)envCtx.lookup(jndiKey); + datasource = (DataSource) envCtx.lookup(jndiKey); Logs.INFO.info("JDBC datasource loaded from JNDI: " + jndiKey); } catch (NamingException e) { @@ -117,7 +116,7 @@ public class JndiDatabaseConnector extends AbstractDatabaseConnector { } datasource = BasicDataSourceFactory.createDataSource(properties); - CustomHibernateConnectionProvider.datasource=datasource; + CustomHibernateConnectionProvider.datasource = datasource; } catch (Exception e) { throw new SonarException("Fail to connect to database", e); } 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 e2c1756d726..eef8c5a475b 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 @@ -52,8 +52,9 @@ public class Review extends Model { * @param id * the id to set */ - public void setId(Long id) { + public Review setId(Long id) { this.id = id; + return this; } /** @@ -67,8 +68,9 @@ public class Review extends Model { * @param createdAt * the createdAt to set */ - public void setCreatedAt(Date createdAt) { + public Review setCreatedAt(Date createdAt) { this.createdAt = createdAt; + return this; } /** @@ -82,8 +84,9 @@ public class Review extends Model { * @param updatedAt * the updatedAt to set */ - public void setUpdatedAt(Date updatedAt) { + public Review setUpdatedAt(Date updatedAt) { this.updatedAt = updatedAt; + return this; } /** @@ -94,11 +97,12 @@ public class Review extends Model { } /** - * @param authorLogin + * @param s * the authorLogin to set */ - public void setAuthorLogin(String authorLogin) { - this.authorLogin = authorLogin; + public Review setAuthorLogin(String s) { + this.authorLogin = s; + return this; } /** @@ -109,11 +113,12 @@ public class Review extends Model { } /** - * @param assigneeLogin + * @param s * the assigneeLogin to set */ - public void setAssigneeLogin(String assigneeLogin) { - this.assigneeLogin = assigneeLogin; + public Review setAssigneeLogin(String s) { + this.assigneeLogin = s; + return this; } /** @@ -124,11 +129,12 @@ public class Review extends Model { } /** - * @param title + * @param s * the title to set */ - public void setTitle(String title) { - this.title = title; + public Review setTitle(String s) { + this.title = s; + return this; } /** @@ -139,11 +145,12 @@ public class Review extends Model { } /** - * @param type + * @param s * the type to set */ - public void setType(String type) { - this.type = type; + public Review setType(String s) { + this.type = s; + return this; } /** @@ -157,8 +164,9 @@ public class Review extends Model { * @param status * the status to set */ - public void setStatus(String status) { + public Review setStatus(String status) { this.status = status; + return this; } /** @@ -172,8 +180,9 @@ public class Review extends Model { * @param severity * the severity to set */ - public void setSeverity(String severity) { + public Review setSeverity(String severity) { this.severity = severity; + return this; } /** @@ -187,8 +196,9 @@ public class Review extends Model { * @param resourceKee * the resourceKee to set */ - public void setResourceKee(String resourceKee) { + public Review setResourceKee(String resourceKee) { this.resourceKee = resourceKee; + return this; } /** @@ -202,8 +212,9 @@ public class Review extends Model { * @param line * the line to set */ - public void setLine(Integer line) { + public Review setLine(Integer line) { this.line = line; + return this; } /** @@ -213,18 +224,15 @@ public class Review extends Model { return comments; } - /** - * @param comments - * the comments to set - */ - public void addComments(Date updatedAt, String authorLogin, String text) { + public Review addComments(Date updatedAt, String authorLogin, String text) { this.comments.add(new Review.Comment(updatedAt, authorLogin, text)); + return this; } /** * @since 2.8 */ - public class Comment extends Model { + public static final class Comment extends Model { private String authorLogin = null; private Date updatedAt = null; |