aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdEngine.java1
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/DefaultResourceCreationLock.java2
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java7
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileProvider.java1
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileWrapper.java6
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/rule/RulesProfileProviderTest.java1
-rw-r--r--sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDataDto.java10
-rw-r--r--sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java3
-rw-r--r--sonar-server/src/main/java/org/sonar/server/plugins/MimeTypes.java7
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/ws/RuleTagsWs.java8
-rw-r--r--sonar-server/src/main/java/org/sonar/server/user/GroupMembershipService.java6
-rw-r--r--sonar-server/src/main/java/org/sonar/server/user/SecurityRealmFactory.java47
-rw-r--r--sonar-server/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java2
-rw-r--r--sonar-testing-harness/src/main/java/org/sonar/api/server/ws/WsTester.java7
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java7
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleTagClient.java7
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/package-info.java22
17 files changed, 82 insertions, 62 deletions
diff --git a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdEngine.java b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdEngine.java
index 3e221e1978c..6e890a6fa18 100644
--- a/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdEngine.java
+++ b/plugins/sonar-cpd-plugin/src/main/java/org/sonar/plugins/cpd/CpdEngine.java
@@ -22,7 +22,6 @@ package org.sonar.plugins.cpd;
import org.slf4j.Logger;
import org.sonar.api.BatchExtension;
import org.sonar.api.batch.SensorContext;
-import org.sonar.api.resources.Language;
import org.sonar.api.resources.Project;
public abstract class CpdEngine implements BatchExtension {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultResourceCreationLock.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultResourceCreationLock.java
index 06c98eddaaa..11d934b5206 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/DefaultResourceCreationLock.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultResourceCreationLock.java
@@ -33,6 +33,8 @@ public final class DefaultResourceCreationLock implements ResourceCreationLock {
@Override
public void lock() {
+ // does nothing since 4.2. Creation of components (ex-resources) is
+ // the responsibility of core, not plugins
}
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java b/sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java
index 9617bc634c5..652462f69c2 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/ProfileLoader.java
@@ -23,9 +23,10 @@ import org.sonar.api.config.Settings;
import org.sonar.api.profiles.RulesProfile;
/**
- * This interface is implemented by the views plugin!!
- *
- */
+ * This interface is implemented by the views plugin!!
+ *
+ * @deprecated in 4.2
+ */
@Deprecated
public interface ProfileLoader {
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileProvider.java b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileProvider.java
index 3af1866b814..f8524749ec8 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileProvider.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileProvider.java
@@ -23,7 +23,6 @@ import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
import org.picocontainer.injectors.ProviderAdapter;
import org.sonar.api.CoreProperties;
-import org.sonar.api.batch.ModuleLanguages;
import org.sonar.api.config.Settings;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.rules.ActiveRule;
diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileWrapper.java b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileWrapper.java
index 6af51ec5473..9e9ea0400e8 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileWrapper.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/rule/RulesProfileWrapper.java
@@ -69,7 +69,7 @@ public class RulesProfileWrapper extends RulesProfile {
@Override
public String getName() {
- return singleLanguageProfile!= null ? singleLanguageProfile.getName() : "SonarQube";
+ return singleLanguageProfile != null ? singleLanguageProfile.getName() : "SonarQube";
}
@Override
@@ -90,8 +90,8 @@ public class RulesProfileWrapper extends RulesProfile {
return profile;
}
}
- return null;
- }
+ return null;
+ }
@Override
public List<Alert> getAlerts() {
diff --git a/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProfileProviderTest.java b/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProfileProviderTest.java
index 1b43540afb3..7cb99823368 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProfileProviderTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/rule/RulesProfileProviderTest.java
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class RulesProfileProviderTest {
+
ModuleQProfiles qProfiles = mock(ModuleQProfiles.class);
Settings settings = new Settings();
ProfilesDao dao = mock(ProfilesDao.class);
diff --git a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDataDto.java b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDataDto.java
index 9c93db63f72..42907586b3f 100644
--- a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDataDto.java
+++ b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDataDto.java
@@ -22,7 +22,7 @@ package org.sonar.core.measure.db;
import com.google.common.base.Charsets;
-import java.io.UnsupportedEncodingException;
+import javax.annotation.CheckForNull;
public class MeasureDataDto {
@@ -70,14 +70,10 @@ public class MeasureDataDto {
return this;
}
+ @CheckForNull
public String getText() {
if (data != null) {
- try {
- return new String(data, Charsets.UTF_8.name());
- } catch (UnsupportedEncodingException e) {
- // how is it possible to not support UTF-8 ?
- throw new RuntimeException("UTF8 is not supported", e);
- }
+ return new String(data, Charsets.UTF_8);
}
return null;
}
diff --git a/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java b/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java
index 41178cb097b..3e970f10733 100644
--- a/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java
+++ b/sonar-server/src/main/java/org/sonar/server/permission/InternalPermissionTemplateService.java
@@ -22,8 +22,6 @@ package org.sonar.server.permission;
import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.sonar.api.ServerComponent;
import org.sonar.core.permission.PermissionTemplateDao;
import org.sonar.core.permission.PermissionTemplateDto;
@@ -32,7 +30,6 @@ import org.sonar.server.exceptions.BadRequestException;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
diff --git a/sonar-server/src/main/java/org/sonar/server/plugins/MimeTypes.java b/sonar-server/src/main/java/org/sonar/server/plugins/MimeTypes.java
index 7ad624f820a..8bbdcb1e6d4 100644
--- a/sonar-server/src/main/java/org/sonar/server/plugins/MimeTypes.java
+++ b/sonar-server/src/main/java/org/sonar/server/plugins/MimeTypes.java
@@ -30,9 +30,6 @@ import java.util.Map;
* @since 3.1
*/
public final class MimeTypes {
- private MimeTypes() {
- // only static methods
- }
public static final String JSON = "application/json";
public static final String XML = "application/xml";
@@ -68,6 +65,10 @@ public final class MimeTypes {
.put("tsv", "text/tab-separated-values")
.build();
+ private MimeTypes() {
+ // only static methods
+ }
+
public static String getByFilename(String filename) {
String extension = FilenameUtils.getExtension(filename);
String mime = null;
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleTagsWs.java b/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleTagsWs.java
index de1dc6047d7..cea8acd55ab 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleTagsWs.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/ws/RuleTagsWs.java
@@ -38,7 +38,7 @@ public class RuleTagsWs implements WebService {
@Override
public void define(Context context) {
NewController controller = context.newController("api/rule_tags")
- .setDescription("Rule tags");
+ .setDescription("Rule tags");
controller.newAction("list")
.setDescription("List all available rule tags")
@@ -46,7 +46,7 @@ public class RuleTagsWs implements WebService {
.setHandler(new RequestHandler() {
@Override
public void handle(Request request, Response response) {
- list(request, response);
+ list(response);
}
});
@@ -65,10 +65,10 @@ public class RuleTagsWs implements WebService {
controller.done();
}
- private void list(Request request, Response response) {
+ private void list(Response response) {
JsonWriter writer = response.newJsonWriter();
writer.beginArray();
- for (String tag: ruleTags.listAllTags()) {
+ for (String tag : ruleTags.listAllTags()) {
writer.value(tag);
}
writer.endArray().close();
diff --git a/sonar-server/src/main/java/org/sonar/server/user/GroupMembershipService.java b/sonar-server/src/main/java/org/sonar/server/user/GroupMembershipService.java
index ec32e47249f..77f0184f26d 100644
--- a/sonar-server/src/main/java/org/sonar/server/user/GroupMembershipService.java
+++ b/sonar-server/src/main/java/org/sonar/server/user/GroupMembershipService.java
@@ -58,10 +58,10 @@ public class GroupMembershipService implements ServerComponent {
String selected = (String) params.get("selected");
if (SELECTED_MEMBERSHIP.equals(selected)) {
return GroupMembershipQuery.IN;
- } else if (DESELECTED_MEMBERSHIP.equals(selected)) {
+ }
+ if (DESELECTED_MEMBERSHIP.equals(selected)) {
return GroupMembershipQuery.OUT;
- } else {
- return GroupMembershipQuery.ANY;
}
+ return GroupMembershipQuery.ANY;
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/user/SecurityRealmFactory.java b/sonar-server/src/main/java/org/sonar/server/user/SecurityRealmFactory.java
index 7b048cdcb4d..99a175f31d1 100644
--- a/sonar-server/src/main/java/org/sonar/server/user/SecurityRealmFactory.java
+++ b/sonar-server/src/main/java/org/sonar/server/user/SecurityRealmFactory.java
@@ -20,6 +20,7 @@
package org.sonar.server.user;
import org.apache.commons.lang.StringUtils;
+import org.picocontainer.Startable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.CoreProperties;
@@ -32,9 +33,7 @@ import org.sonar.api.utils.SonarException;
/**
* @since 2.14
*/
-public class SecurityRealmFactory implements ServerComponent {
-
- private static final Logger INFO = LoggerFactory.getLogger("org.sonar.INFO");
+public class SecurityRealmFactory implements ServerComponent, Startable {
private final boolean ignoreStartupFailure;
private final SecurityRealm realm;
@@ -47,14 +46,15 @@ public class SecurityRealmFactory implements ServerComponent {
if (!StringUtils.isEmpty(realmName)) {
selectedRealm = selectRealm(realms, realmName);
if (selectedRealm == null) {
- throw new SonarException("Realm '" + realmName + "' not found. Please check the property '" + CoreProperties.CORE_AUTHENTICATOR_REALM + "' in conf/sonar.properties");
+ throw new SonarException(String.format(
+ "Realm '%s' not found. Please check the property '%s' in conf/sonar.properties", realmName, CoreProperties.CORE_AUTHENTICATOR_REALM));
}
}
if (selectedRealm == null && !StringUtils.isEmpty(className)) {
LoginPasswordAuthenticator authenticator = selectAuthenticator(authenticators, className);
if (authenticator == null) {
- throw new SonarException("Authenticator '" + className + "' not found. Please check the property '" + CoreProperties.CORE_AUTHENTICATOR_CLASS
- + "' in conf/sonar.properties");
+ throw new SonarException(String.format(
+ "Authenticator '%s' not found. Please check the property '%s' in conf/sonar.properties", className, CoreProperties.CORE_AUTHENTICATOR_CLASS));
}
selectedRealm = new CompatibilityRealm(authenticator);
}
@@ -62,26 +62,28 @@ public class SecurityRealmFactory implements ServerComponent {
}
public SecurityRealmFactory(Settings settings, LoginPasswordAuthenticator[] authenticators) {
- this(settings, null, authenticators);
+ this(settings, new SecurityRealm[0], authenticators);
}
public SecurityRealmFactory(Settings settings, SecurityRealm[] realms) {
- this(settings, realms, null);
+ this(settings, realms, new LoginPasswordAuthenticator[0]);
}
public SecurityRealmFactory(Settings settings) {
- this(settings, null, null);
+ this(settings, new SecurityRealm[0], new LoginPasswordAuthenticator[0]);
}
+ @Override
public void start() {
if (realm != null) {
+ Logger logger = LoggerFactory.getLogger("org.sonar.INFO");
try {
- INFO.info("Security realm: " + realm.getName());
+ logger.info("Security realm: " + realm.getName());
realm.init();
- INFO.info("Security realm started");
+ logger.info("Security realm started");
} catch (RuntimeException e) {
if (ignoreStartupFailure) {
- INFO.error("IGNORED - Security realm fails to start: " + e.getMessage());
+ logger.error("IGNORED - Security realm fails to start: " + e.getMessage());
} else {
throw new SonarException("Security realm fails to start: " + e.getMessage(), e);
}
@@ -89,27 +91,28 @@ public class SecurityRealmFactory implements ServerComponent {
}
}
+ @Override
+ public void stop() {
+ // nothing
+ }
+
public SecurityRealm getRealm() {
return realm;
}
private static SecurityRealm selectRealm(SecurityRealm[] realms, String realmName) {
- if (realms != null) {
- for (SecurityRealm realm : realms) {
- if (StringUtils.equals(realmName, realm.getName())) {
- return realm;
- }
+ for (SecurityRealm realm : realms) {
+ if (StringUtils.equals(realmName, realm.getName())) {
+ return realm;
}
}
return null;
}
private static LoginPasswordAuthenticator selectAuthenticator(LoginPasswordAuthenticator[] authenticators, String className) {
- if (authenticators != null) {
- for (LoginPasswordAuthenticator lpa : authenticators) {
- if (lpa.getClass().getName().equals(className)) {
- return lpa;
- }
+ for (LoginPasswordAuthenticator lpa : authenticators) {
+ if (lpa.getClass().getName().equals(className)) {
+ return lpa;
}
}
return null;
diff --git a/sonar-server/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java b/sonar-server/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java
index 70bd0be1b7f..d571d2f9ac5 100644
--- a/sonar-server/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/user/SecurityRealmFactoryTest.java
@@ -47,6 +47,8 @@ public class SecurityRealmFactoryTest {
factory.start();
assertThat(factory.getRealm()).isSameAs(realm);
verify(realm).init();
+
+ factory.stop();
}
@Test
diff --git a/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/WsTester.java b/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/WsTester.java
index 4e1c774e74d..568f0b4cb7e 100644
--- a/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/WsTester.java
+++ b/sonar-testing-harness/src/main/java/org/sonar/api/server/ws/WsTester.java
@@ -26,7 +26,6 @@ import org.sonar.api.utils.text.JsonWriter;
import org.sonar.api.utils.text.XmlWriter;
import javax.annotation.CheckForNull;
-
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
@@ -34,8 +33,6 @@ import java.net.URL;
import java.util.HashMap;
import java.util.Map;
-import static org.fest.assertions.Assertions.assertThat;
-
/**
* @since 4.2
*/
@@ -104,6 +101,10 @@ public class WsTester {
return mediaType;
}
+ public int status() {
+ return status;
+ }
+
@Override
public Response.Stream setMediaType(String s) {
this.mediaType = s;
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
index e20513ee7f2..525505bcd14 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java
@@ -23,20 +23,17 @@ import com.github.kevinsawicki.http.HttpRequest;
import org.sonar.wsclient.base.HttpException;
import javax.annotation.Nullable;
-
import java.util.Arrays;
import java.util.Map;
-import static java.net.HttpURLConnection.HTTP_CREATED;
-import static java.net.HttpURLConnection.HTTP_NO_CONTENT;
-import static java.net.HttpURLConnection.HTTP_OK;
+import static java.net.HttpURLConnection.*;
/**
* Not an API. Please do not use this class, except maybe for unit tests.
*/
public class HttpRequestFactory {
- private final static int[] RESPONSE_SUCCESS = {HTTP_OK, HTTP_CREATED, HTTP_NO_CONTENT};
+ private static final int[] RESPONSE_SUCCESS = {HTTP_OK, HTTP_CREATED, HTTP_NO_CONTENT};
private final String baseUrl;
private String login, password, proxyHost, proxyLogin, proxyPassword;
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleTagClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleTagClient.java
index 43f9101a9b2..58bbfe72b6c 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleTagClient.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/DefaultRuleTagClient.java
@@ -25,7 +25,7 @@ import org.sonar.wsclient.rule.RuleTagClient;
import java.util.Collection;
import java.util.HashMap;
-import java.util.List;
+import java.util.Map;
/**
* Do not instantiate this class, but use {@link org.sonar.wsclient.SonarClient#ruleTagClient()}.
@@ -46,13 +46,12 @@ public class DefaultRuleTagClient implements RuleTagClient {
@SuppressWarnings("unchecked")
public Collection<String> list() {
String json = requestFactory.get(LIST_URL, null);
- final List<String> tagList = (List<String>) JSONValue.parse(json);
- return tagList;
+ return (Collection<String>) JSONValue.parse(json);
}
@Override
public void create(String tag) {
- final HashMap<String, Object> params = new HashMap<String, Object>();
+ Map<String, Object> params = new HashMap<String, Object>();
params.put("tag", tag);
requestFactory.post(CREATE_URL, params);
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/package-info.java
new file mode 100644
index 00000000000..003389a31b4
--- /dev/null
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/internal/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * SonarQube is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+@ParametersAreNonnullByDefault package org.sonar.wsclient.rule.internal;
+
+import javax.annotation.ParametersAreNonnullByDefault;