From bcc445118956633eb4084581a47edbe5672cefb4 Mon Sep 17 00:00:00 2001 From: simonbrandhof Date: Thu, 5 May 2011 15:08:04 +0200 Subject: [PATCH] Reduce technical debt --- .../plugins/checkstyle/CheckstyleSensor.java | 1 - .../plugins/cobertura/api/CoberturaUtils.java | 1 + .../ViolationPersisterDecorator.java | 9 ++- .../plugins/findbugs/FindbugsSensor.java | 1 - .../java/org/sonar/plugins/pmd/PmdSensor.java | 5 +- .../java/squid/check/EmptyFileCheck.java | 4 +- .../plugins/surefire/SurefirePlugin.java | 6 +- .../java/org/sonar/channel/RegexChannel.java | 2 +- .../org/sonar/markdown/HtmlListChannel.java | 5 +- .../org/sonar/markdown/MarkdownEngine.java | 42 ++++++++------ .../src/main/java/org/sonar/api/Plugin.java | 1 + .../org/sonar/api/batch/DecoratorContext.java | 2 +- .../web/gwt/client/ResourceDictionary.java | 4 ++ .../org/sonar/api/web/gwt/client/Utils.java | 2 + .../client/webservices/BaseQueryCallback.java | 4 ++ .../webservices/JSONHandlerDispatcher.java | 4 ++ .../web/gwt/client/webservices/JsonUtils.java | 4 ++ .../api/web/gwt/client/webservices/Query.java | 4 ++ .../gwt/client/webservices/QueryCallBack.java | 4 ++ .../gwt/client/webservices/ResponsePOJO.java | 4 ++ .../client/webservices/SequentialQueries.java | 4 ++ .../gwt/client/webservices/VoidResponse.java | 4 ++ .../web/gwt/client/webservices/WSMetrics.java | 4 ++ .../CustomHibernateConnectionProvider.java | 3 +- .../database/JndiDatabaseConnector.java | 5 +- .../org/sonar/wsclient/services/Review.java | 58 +++++++++++-------- 26 files changed, 124 insertions(+), 63 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 violationMap) { + private boolean isNotAlreadyMapped(Violation newViolation, Map 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 extends Channel { } 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 { try { if (code.getColumnPosition() == 0 && listElement.consume(code, output)) { while (endOfLine.consume(code, output) && listElement.consume(code, output)) { + // consume input } output.append(""); return true; @@ -52,7 +53,7 @@ class HtmlListChannel extends Channel { @Override protected void consume(CharSequence token, MarkdownOutput output) { - if ( !pendingListConstruction) { + if (!pendingListConstruction) { output.append("
    "); pendingListConstruction = true; } @@ -75,7 +76,7 @@ class HtmlListChannel extends Channel { } } - private class EndOfLine extends RegexChannel { + private static final class EndOfLine extends RegexChannel { 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 dispatcher; private MarkdownEngine() { - output = new MarkdownOutput(); - List markdownChannels = new ArrayList(); - 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 markdownChannels = Arrays.asList( + new HtmlUrlChannel(), + new HtmlEndOfLineChannel(), + new HtmlEmphasisChannel(), + new HtmlListChannel(), + new HtmlCodeChannel(), + new IdentifierAndNumberChannel(), + new BlackholeChannel()); dispatcher = new ChannelDispatcher(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 getViolations(ViolationQuery violationQuery); + abstract List 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/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

    implements QueryCallBack

    { private LoadingLabel loading; 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

    implements JsonUtils.JSONHandler { private QueryCallBack

    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/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 { public abstract void execute(final QueryCallBack 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 { 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 { private List> queries = new ArrayList>(); 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; -- 2.39.5