aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/main/java/org/sonar/api
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-plugin-api/src/main/java/org/sonar/api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaData.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/ProjectClasspath.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachineQuery.java16
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java7
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilder.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/config/License.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java13
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java9
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java21
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java9
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java12
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypeTree.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileExclusions.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/PathResolver.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/ws/internal/ValidatingRequest.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/FieldUtils2.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java311
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpsTrust.java99
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java16
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/command/Command.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/web/Filter.java9
29 files changed, 102 insertions, 506 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaData.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaData.java
index 6cff32c4d1a..1aa4bc24193 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaData.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DefaultFormulaData.java
@@ -19,12 +19,12 @@
*/
package org.sonar.api.batch;
-import com.google.common.collect.Lists;
import org.sonar.api.measures.FormulaData;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.measures.Metric;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -61,7 +61,7 @@ public class DefaultFormulaData implements FormulaData {
@Override
public Collection<FormulaData> getChildren() {
- List<FormulaData> result = Lists.newArrayList();
+ List<FormulaData> result = new ArrayList<>();
for (DecoratorContext childContext : decoratorContext.getChildren()) {
result.add(new DefaultFormulaData(childContext));
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/ProjectClasspath.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/ProjectClasspath.java
index f7d55073bc5..98502636ad2 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/ProjectClasspath.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/ProjectClasspath.java
@@ -19,7 +19,6 @@
*/
package org.sonar.api.batch;
-import com.google.common.collect.Lists;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.project.MavenProject;
import org.sonar.api.BatchComponent;
@@ -29,6 +28,7 @@ import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -65,7 +65,7 @@ public class ProjectClasspath implements BatchComponent {
protected URLClassLoader createClassLoader() {
try {
- List<URL> urls = Lists.newArrayList();
+ List<URL> urls = new ArrayList<>();
for (File file : getElements()) {
urls.add(file.toURI().toURL());
}
@@ -78,7 +78,7 @@ public class ProjectClasspath implements BatchComponent {
protected List<File> createElements() {
try {
- List<File> files = Lists.newArrayList();
+ List<File> files = new ArrayList<>();
if (pom.getCompileClasspathElements() != null) {
for (String classPathString : pom.getCompileClasspathElements()) {
files.add(new File(classPathString));
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachineQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachineQuery.java
index 4ac061e3bed..e4d5482ad5f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachineQuery.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/TimeMachineQuery.java
@@ -19,13 +19,13 @@
*/
package org.sonar.api.batch;
-import com.google.common.collect.Lists;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.sonar.api.measures.Metric;
import org.sonar.api.resources.Resource;
import java.util.Arrays;
import java.util.Date;
+import java.util.LinkedList;
import java.util.List;
/**
@@ -91,7 +91,7 @@ public class TimeMachineQuery {
*/
public TimeMachineQuery setMetrics(List<Metric> metrics) {
this.metrics = metrics;
- this.metricKeys = Lists.newLinkedList();
+ this.metricKeys = new LinkedList<>();
for (Metric metric : this.metrics) {
this.metricKeys.add(metric.getKey());
}
@@ -120,7 +120,7 @@ public class TimeMachineQuery {
*/
public TimeMachineQuery setMetrics(Metric... metrics) {
this.metrics = Arrays.asList(metrics);
- this.metricKeys = Lists.newLinkedList();
+ this.metricKeys = new LinkedList<>();
for (Metric metric : this.metrics) {
this.metricKeys.add(metric.getKey());
}
@@ -225,10 +225,10 @@ public class TimeMachineQuery {
@Override
public String toString() {
return new ToStringBuilder(this)
- .append("resource", resource)
- .append("metrics", metrics)
- .append("from", from)
- .append("to", to)
- .toString();
+ .append("resource", resource)
+ .append("metrics", metrics)
+ .append("from", from)
+ .append("to", to)
+ .toString();
}
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
index afc120524a5..9f123486313 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java
@@ -19,7 +19,6 @@
*/
package org.sonar.api.batch.bootstrap;
-import com.google.common.collect.Lists;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.CoreProperties;
@@ -80,8 +79,8 @@ public class ProjectDefinition {
private File baseDir, workDir, buildDir;
private Map<String, String> properties = new HashMap<String, String>();
private ProjectDefinition parent = null;
- private List<ProjectDefinition> subProjects = Lists.newArrayList();
- private List<Object> containerExtensions = Lists.newArrayList();
+ private List<ProjectDefinition> subProjects = new ArrayList<>();
+ private List<Object> containerExtensions = new ArrayList<>();
private ProjectDefinition(Properties p) {
for (Entry<Object, Object> entry : p.entrySet()) {
@@ -603,7 +602,7 @@ public class ProjectDefinition {
}
private static List<String> trim(String[] strings) {
- List<String> result = Lists.newArrayList();
+ List<String> result = new ArrayList<>();
for (String s : strings) {
result.add(StringUtils.trim(s));
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
index 5cdc2aba2b3..b755da6f5b5 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
@@ -32,6 +32,8 @@ import javax.annotation.CheckForNull;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
@@ -82,8 +84,8 @@ import java.util.Map;
public class Checks<C> {
private final ActiveRules activeRules;
private final String repository;
- private final Map<RuleKey, C> checkByRule = Maps.newHashMap();
- private final Map<C, RuleKey> ruleByCheck = Maps.newIdentityHashMap();
+ private final Map<RuleKey, C> checkByRule = new HashMap<>();
+ private final Map<C, RuleKey> ruleByCheck = new IdentityHashMap<>();
Checks(ActiveRules activeRules, String repository) {
this.activeRules = activeRules;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilder.java
index 24edaa4e763..6e23900143b 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/ActiveRulesBuilder.java
@@ -19,10 +19,10 @@
*/
package org.sonar.api.batch.rule.internal;
-import com.google.common.collect.Maps;
import org.sonar.api.batch.rule.ActiveRules;
import org.sonar.api.rule.RuleKey;
+import java.util.LinkedHashMap;
import java.util.Map;
/**
@@ -33,7 +33,7 @@ import java.util.Map;
*/
public class ActiveRulesBuilder {
- private final Map<RuleKey, NewActiveRule> map = Maps.newLinkedHashMap();
+ private final Map<RuleKey, NewActiveRule> map = new LinkedHashMap<>();
public NewActiveRule create(RuleKey ruleKey) {
return new NewActiveRule(this, ruleKey);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/License.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/License.java
index d0f53d44024..8760b8f8d2e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/License.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/License.java
@@ -33,6 +33,7 @@ import java.io.IOException;
import java.io.StringReader;
import java.util.Calendar;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -51,7 +52,7 @@ public final class License {
private Map<String, String> additionalProperties;
private License(Map<String, String> properties) {
- this.additionalProperties = Maps.newHashMap(properties);
+ this.additionalProperties = new HashMap<>(properties);
product = StringUtils.defaultString(get("Product", properties), get("Plugin", properties));
organization = StringUtils.defaultString(get("Organisation", properties), get("Name", properties));
expirationDate = StringUtils.defaultString(get("Expiration", properties), get("Expires", properties));
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java
index 8e9b3d5df10..c8c73bde7e5 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java
@@ -33,11 +33,10 @@ import org.sonar.api.resources.Qualifiers;
import javax.annotation.Nullable;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import static com.google.common.collect.Lists.newArrayList;
-
/**
* Declare a plugin property. Values are available at runtime through the component {@link Settings}.
* <p/>
@@ -127,7 +126,7 @@ public final class PropertyDefinition implements BatchExtension, ServerExtension
.propertySetKey(annotation.propertySetKey())
.fields(PropertyFieldDefinition.create(annotation.fields()))
.deprecatedKey(annotation.deprecatedKey());
- List<String> qualifiers = newArrayList();
+ List<String> qualifiers = new ArrayList<>();
if (annotation.project()) {
qualifiers.add(Qualifiers.PROJECT);
}
@@ -322,14 +321,14 @@ public final class PropertyDefinition implements BatchExtension, ServerExtension
* @see PropertyDefinition.Builder#subCategory(String)
*/
private String subCategory = "";
- private List<String> onQualifiers = newArrayList();
- private List<String> onlyOnQualifiers = newArrayList();
+ private List<String> onQualifiers = new ArrayList<>();
+ private List<String> onlyOnQualifiers = new ArrayList<>();
private boolean global = true;
private PropertyType type = PropertyType.STRING;
- private List<String> options = newArrayList();
+ private List<String> options = new ArrayList<>();
private boolean multiValues = false;
private String propertySetKey = "";
- private List<PropertyFieldDefinition> fields = newArrayList();
+ private List<PropertyFieldDefinition> fields = new ArrayList<>();
private String deprecatedKey = "";
private boolean hidden = false;
private int index = 999;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java
index 02c86f06023..b44f6696d27 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinitions.java
@@ -20,7 +20,6 @@
package org.sonar.api.config;
import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.BatchComponent;
import org.sonar.api.CoreProperties;
@@ -44,12 +43,12 @@ import java.util.Map;
*/
public final class PropertyDefinitions implements BatchComponent, ServerComponent {
- private final Map<String, PropertyDefinition> definitions = Maps.newHashMap();
- private final Map<String, Category> categories = Maps.newHashMap();
- private final Map<String, SubCategory> subcategories = Maps.newHashMap();
+ private final Map<String, PropertyDefinition> definitions = new HashMap<>();
+ private final Map<String, Category> categories = new HashMap<>();
+ private final Map<String, SubCategory> subcategories = new HashMap<>();
// deprecated key -> new key
- private final Map<String, String> deprecatedKeys = Maps.newHashMap();
+ private final Map<String, String> deprecatedKeys = new HashMap<>();
public PropertyDefinitions(Object... components) {
if (components != null) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java
index 06d856790de..93b68d49878 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyFieldDefinition.java
@@ -27,10 +27,9 @@ import org.sonar.api.PropertyType;
import javax.annotation.Nullable;
+import java.util.ArrayList;
import java.util.List;
-import static com.google.common.collect.Lists.newArrayList;
-
/**
* @since 3.3
*/
@@ -52,16 +51,16 @@ public final class PropertyFieldDefinition {
}
static List<PropertyFieldDefinition> create(PropertyField[] fields) {
- List<PropertyFieldDefinition> definitions = newArrayList();
+ List<PropertyFieldDefinition> definitions = new ArrayList<>();
for (PropertyField field : fields) {
definitions.add(PropertyFieldDefinition.build(field.key())
- .name(field.name())
- .description(field.description())
- .indicativeSize(field.indicativeSize())
- .type(field.type())
- .options(field.options())
- .build()
- );
+ .name(field.name())
+ .description(field.description())
+ .indicativeSize(field.indicativeSize())
+ .type(field.type())
+ .options(field.options())
+ .build()
+ );
}
return definitions;
}
@@ -112,7 +111,7 @@ public final class PropertyFieldDefinition {
this.description = "";
this.indicativeSize = 20;
this.type = PropertyType.STRING;
- this.options = newArrayList();
+ this.options = new ArrayList<>();
}
public Builder name(String name) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java
index fa422fa815f..662c661d195 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/Settings.java
@@ -23,7 +23,6 @@ import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
@@ -33,6 +32,7 @@ import org.sonar.api.utils.DateUtils;
import javax.annotation.Nullable;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -235,7 +235,7 @@ public class Settings implements BatchComponent, ServerComponent {
return ArrayUtils.EMPTY_STRING_ARRAY;
}
- List<String> values = Lists.newArrayList();
+ List<String> values = new ArrayList<>();
for (String v : Splitter.on(",").trimResults().split(value)) {
values.add(v.replace("%2C", ","));
}
@@ -276,7 +276,7 @@ public class Settings implements BatchComponent, ServerComponent {
}
public List<String> getKeysStartingWith(String prefix) {
- List<String> result = Lists.newArrayList();
+ List<String> result = new ArrayList<>();
for (String key : properties.keySet()) {
if (StringUtils.startsWith(key, prefix)) {
result.add(key);
@@ -303,7 +303,7 @@ public class Settings implements BatchComponent, ServerComponent {
String text = null;
if (values != null) {
- List<String> escaped = Lists.newArrayList();
+ List<String> escaped = new ArrayList<>();
for (String value : values) {
if (null != value) {
escaped.add(value.replace(",", "%2C"));
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java
index b13b2a4806a..149a7450994 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/action/Actions.java
@@ -22,21 +22,16 @@ package org.sonar.api.issue.action;
import com.google.common.annotations.Beta;
import org.sonar.api.ServerExtension;
+import java.util.ArrayList;
import java.util.List;
-import static com.google.common.collect.Lists.newArrayList;
-
/**
* @since 3.6
*/
@Beta
public class Actions implements ServerExtension {
- private final List<Action> actions;
-
- public Actions() {
- actions = newArrayList();
- }
+ private final List<Action> actions = new ArrayList<>();
public Action add(String actionKey) {
Action action = new Action(actionKey);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java
index d2827256243..db09f62cef2 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java
@@ -42,8 +42,6 @@ import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.*;
-import static com.google.common.collect.Lists.newArrayList;
-
/**
* PLUGINS MUST NOT BE USED THIS CLASS, EXCEPT FOR UNIT TESTING.
*
@@ -506,7 +504,7 @@ public class DefaultIssue implements Issue {
public DefaultIssue addChange(FieldDiffs change) {
if (changes == null) {
- changes = newArrayList();
+ changes = new ArrayList<>();
}
changes.add(change);
return this;
@@ -526,7 +524,7 @@ public class DefaultIssue implements Issue {
public DefaultIssue addComment(DefaultIssueComment comment) {
if (comments == null) {
- comments = newArrayList();
+ comments = new ArrayList<>();
}
comments.add(comment);
return this;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
index 3427c5a8461..7b3dddee46d 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
@@ -22,7 +22,6 @@ package org.sonar.api.measures;
import com.google.common.annotations.Beta;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
import org.sonar.api.resources.Scopes;
import org.sonar.api.test.MutableTestPlan;
import org.sonar.api.utils.SonarException;
@@ -31,6 +30,7 @@ import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.util.LinkedList;
import java.util.List;
/**
@@ -2226,7 +2226,7 @@ public final class CoreMetrics {
private static final List<Metric> METRICS;
static {
- METRICS = Lists.newLinkedList();
+ METRICS = new LinkedList<>();
for (Field field : CoreMetrics.class.getFields()) {
if (!Modifier.isTransient(field.getModifiers()) && Metric.class.isAssignableFrom(field.getType())) {
try {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java
index 823155b2d0a..d4ddac91853 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java
@@ -19,10 +19,10 @@
*/
package org.sonar.api.measures;
-import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.sonar.api.utils.KeyValueFormat;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -110,7 +110,7 @@ public final class CoverageMeasuresBuilder {
}
public Collection<Measure> createMeasures() {
- Collection<Measure> measures = Lists.newArrayList();
+ Collection<Measure> measures = new ArrayList<>();
if (getLinesToCover() > 0) {
measures.add(new Measure(CoreMetrics.LINES_TO_COVER, (double) getLinesToCover()));
measures.add(new Measure(CoreMetrics.UNCOVERED_LINES, (double) (getLinesToCover() - getCoveredLines())));
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
index 15f8bd4b4cf..a541337ca97 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java
@@ -21,7 +21,6 @@ package org.sonar.api.profiles;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.Transformer;
import org.apache.commons.lang.StringUtils;
@@ -34,7 +33,6 @@ import org.sonar.api.utils.MessageException;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-
import java.util.ArrayList;
import java.util.List;
@@ -68,7 +66,7 @@ public class RulesProfile implements Cloneable {
private Boolean defaultProfile = Boolean.FALSE;
private String language;
private String parentName;
- private List<ActiveRule> activeRules = Lists.newArrayList();
+ private List<ActiveRule> activeRules = new ArrayList<>();
/**
* @deprecated use the factory method create()
@@ -84,7 +82,7 @@ public class RulesProfile implements Cloneable {
public RulesProfile(String name, String language) {
this.name = name;
this.language = language;
- this.activeRules = Lists.newArrayList();
+ this.activeRules = new ArrayList<>();
}
/**
@@ -163,7 +161,7 @@ public class RulesProfile implements Cloneable {
if (acceptDisabledRules) {
return activeRules;
}
- List<ActiveRule> result = Lists.newArrayList();
+ List<ActiveRule> result = new ArrayList<>();
for (ActiveRule activeRule : activeRules) {
if (activeRule.isEnabled()) {
result.add(activeRule);
@@ -244,7 +242,7 @@ public class RulesProfile implements Cloneable {
* @return the list of active rules for a given severity
*/
public List<ActiveRule> getActiveRules(RulePriority severity) {
- List<ActiveRule> result = Lists.newArrayList();
+ List<ActiveRule> result = new ArrayList<>();
for (ActiveRule activeRule : activeRules) {
if (activeRule.getSeverity().equals(severity) && activeRule.isEnabled()) {
result.add(activeRule);
@@ -258,7 +256,7 @@ public class RulesProfile implements Cloneable {
* Only enabled rules are selected. Disabled rules are excluded.
*/
public List<ActiveRule> getActiveRulesByRepository(String repositoryKey) {
- List<ActiveRule> result = Lists.newArrayList();
+ List<ActiveRule> result = new ArrayList<>();
for (ActiveRule activeRule : activeRules) {
if (repositoryKey.equals(activeRule.getRepositoryKey()) && activeRule.isEnabled()) {
result.add(activeRule);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java
index 51a6cde057e..07457c92729 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/InputFileUtils.java
@@ -28,6 +28,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -47,7 +48,7 @@ public final class InputFileUtils {
* @return not null list
*/
public static List<java.io.File> toFiles(Collection<InputFile> inputFiles) {
- List<java.io.File> files = Lists.newArrayList();
+ List<java.io.File> files = new ArrayList<>();
for (InputFile inputFile : inputFiles) {
files.add(inputFile.getFile());
}
@@ -89,7 +90,7 @@ public final class InputFileUtils {
* For internal and for testing purposes. Please use the FileSystem component to access files.
*/
public static List<InputFile> create(java.io.File basedir, Collection<java.io.File> files) {
- List<InputFile> inputFiles = Lists.newArrayList();
+ List<InputFile> inputFiles = new ArrayList<>();
for (File file : files) {
InputFile inputFile = create(basedir, file);
if (inputFile != null) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypeTree.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypeTree.java
index c6e4031f9e2..f6fa337b482 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypeTree.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ResourceTypeTree.java
@@ -26,10 +26,10 @@ import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ListMultimap;
-import com.google.common.collect.Lists;
import org.sonar.api.ServerExtension;
import org.sonar.api.task.TaskExtension;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -80,7 +80,7 @@ public class ResourceTypeTree implements TaskExtension, ServerExtension {
}
public static final class Builder {
- private List<ResourceType> types = Lists.newArrayList();
+ private List<ResourceType> types = new ArrayList<>();
private ListMultimap<String, String> relations = ArrayListMultimap.create();
private ResourceType root;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileExclusions.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileExclusions.java
index a49829e9c20..b5032895f83 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileExclusions.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/FileExclusions.java
@@ -19,13 +19,13 @@
*/
package org.sonar.api.scan.filesystem;
-import com.google.common.collect.Lists;
import com.google.common.collect.ObjectArrays;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.BatchComponent;
import org.sonar.api.CoreProperties;
import org.sonar.api.config.Settings;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -52,7 +52,7 @@ public class FileExclusions implements BatchComponent {
private String[] inclusions(String propertyKey) {
String[] patterns = sanitize(settings.getStringArray(propertyKey));
- List<String> list = Lists.newArrayList();
+ List<String> list = new ArrayList<>();
for (String pattern : patterns) {
if (!"**/*".equals(pattern) && !"file:**/*".equals(pattern)) {
list.add(pattern);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/PathResolver.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/PathResolver.java
index 6da18e4a049..9bd4ac7be0c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/PathResolver.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/PathResolver.java
@@ -21,13 +21,13 @@ package org.sonar.api.scan.filesystem;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
import org.sonar.api.BatchComponent;
import org.sonar.api.utils.PathUtils;
import javax.annotation.CheckForNull;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -50,7 +50,7 @@ public class PathResolver implements BatchComponent {
}
public List<File> relativeFiles(File dir, List<String> paths) {
- List<File> result = Lists.newArrayList();
+ List<File> result = new ArrayList<>();
for (String path : paths) {
result.add(relativeFile(dir, path));
}
@@ -59,7 +59,7 @@ public class PathResolver implements BatchComponent {
@CheckForNull
public RelativePath relativePath(Collection<File> dirs, File file) {
- List<String> stack = Lists.newArrayList();
+ List<String> stack = new ArrayList<>();
File cursor = file;
while (cursor != null) {
File parentDir = parentDir(dirs, cursor);
@@ -74,7 +74,7 @@ public class PathResolver implements BatchComponent {
@CheckForNull
public String relativePath(File dir, File file) {
- List<String> stack = Lists.newArrayList();
+ List<String> stack = new ArrayList<>();
String dirPath = PathUtils.canonicalPath(dir);
File cursor = file;
while (cursor != null) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java
index 2cbd0ef0b4d..427350b2ea6 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/Request.java
@@ -28,6 +28,7 @@ import org.sonar.api.utils.SonarException;
import javax.annotation.CheckForNull;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -187,7 +188,7 @@ public abstract class Request {
return null;
}
Iterable<String> values = Splitter.on(',').omitEmptyStrings().trimResults().split(value);
- List<E> result = Lists.newArrayList();
+ List<E> result = new ArrayList<>();
for (String s : values) {
result.add(Enum.valueOf(enumClass, s));
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/internal/ValidatingRequest.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/internal/ValidatingRequest.java
index 054ba773196..af6d5cb7a2e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/internal/ValidatingRequest.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/internal/ValidatingRequest.java
@@ -30,6 +30,7 @@ import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -94,7 +95,7 @@ public abstract class ValidatingRequest extends Request {
return null;
}
Iterable<String> values = Splitter.on(',').omitEmptyStrings().trimResults().split(value);
- List<E> result = Lists.newArrayList();
+ List<E> result = new ArrayList<>();
for (String s : values) {
validate(s, definition);
result.add(Enum.valueOf(enumClass, s));
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/FieldUtils2.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/FieldUtils2.java
index 85f466672aa..2acdbe27537 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/FieldUtils2.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/FieldUtils2.java
@@ -19,11 +19,11 @@
*/
package org.sonar.api.utils;
-import com.google.common.collect.Lists;
import org.apache.commons.lang.ClassUtils;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -44,13 +44,13 @@ public final class FieldUtils2 {
* <code>False</code> only matches public fields.
*/
public static List<Field> getFields(Class clazz, boolean forceAccess) {
- List<Field> result = Lists.newArrayList();
+ List<Field> result = new ArrayList<>();
Class c = clazz;
while (c != null) {
for (Field declaredField : c.getDeclaredFields()) {
if (!Modifier.isPublic(declaredField.getModifiers())) {
if (forceAccess) {
- declaredField.setAccessible(true);//NOSONAR only works from sufficiently privileged code
+ declaredField.setAccessible(true);// NOSONAR only works from sufficiently privileged code
} else {
continue;
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
index ee0ba26214c..2c0ae79479c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpDownloader.java
@@ -19,322 +19,25 @@
*/
package org.sonar.api.utils;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Joiner;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.io.ByteStreams;
-import com.google.common.io.CharStreams;
-import com.google.common.io.Files;
-import com.google.common.io.InputSupplier;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.commons.io.Charsets;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
import org.sonar.api.BatchComponent;
import org.sonar.api.ServerComponent;
-import org.sonar.api.config.Settings;
-import org.sonar.api.platform.Server;
-import org.sonar.api.utils.log.Loggers;
-
-import javax.annotation.Nullable;
import java.io.File;
-import java.io.IOException;
import java.io.InputStream;
-import java.net.Authenticator;
-import java.net.HttpURLConnection;
-import java.net.PasswordAuthentication;
-import java.net.Proxy;
-import java.net.ProxySelector;
import java.net.URI;
-import java.nio.charset.Charset;
-import java.util.List;
-import java.util.Map;
-import java.util.zip.GZIPInputStream;
/**
- * This component downloads HTTP files
- *
- * @since 2.2
+ * This component is available in IoC container, so it should be injected through
+ * a constructor parameter. It is available in both batch and server.
*/
-public class HttpDownloader extends UriReader.SchemeProcessor implements BatchComponent, ServerComponent {
- public static final int TIMEOUT_MILLISECONDS = 20 * 1000;
-
- private final BaseHttpDownloader downloader;
- private final Integer readTimeout;
-
- public HttpDownloader(Server server, Settings settings) {
- this(server, settings, null);
- }
-
- public HttpDownloader(Server server, Settings settings, @Nullable Integer readTimeout) {
- this.readTimeout = readTimeout;
- downloader = new BaseHttpDownloader(settings.getProperties(), server.getVersion());
- }
-
- public HttpDownloader(Settings settings) {
- this(settings, null);
- }
-
- public HttpDownloader(Settings settings, @Nullable Integer readTimeout) {
- this.readTimeout = readTimeout;
- downloader = new BaseHttpDownloader(settings.getProperties(), null);
- }
-
- @Override
- String description(URI uri) {
- return String.format("%s (%s)", uri.toString(), getProxySynthesis(uri));
- }
-
- @Override
- String[] getSupportedSchemes() {
- return new String[] {"http", "https"};
- }
-
- @Override
- byte[] readBytes(URI uri) {
- return download(uri);
- }
-
- @Override
- String readString(URI uri, Charset charset) {
- try {
- return CharStreams.toString(CharStreams.newReaderSupplier(downloader.newInputSupplier(uri, this.readTimeout), charset));
- } catch (IOException e) {
- throw failToDownload(uri, e);
- }
- }
-
- public String downloadPlainText(URI uri, String encoding) {
- return readString(uri, Charset.forName(encoding));
- }
-
- public byte[] download(URI uri) {
- try {
- return ByteStreams.toByteArray(downloader.newInputSupplier(uri, this.readTimeout));
- } catch (IOException e) {
- throw failToDownload(uri, e);
- }
- }
-
- public String getProxySynthesis(URI uri) {
- return downloader.getProxySynthesis(uri);
- }
-
- public InputStream openStream(URI uri) {
- try {
- return downloader.newInputSupplier(uri, this.readTimeout).getInput();
- } catch (IOException e) {
- throw failToDownload(uri, e);
- }
- }
-
- public void download(URI uri, File toFile) {
- try {
- Files.copy(downloader.newInputSupplier(uri, this.readTimeout), toFile);
- } catch (IOException e) {
- FileUtils.deleteQuietly(toFile);
- throw failToDownload(uri, e);
- }
- }
-
- private SonarException failToDownload(URI uri, IOException e) {
- throw new SonarException(String.format("Fail to download: %s (%s)", uri, getProxySynthesis(uri)), e);
- }
-
- public static class BaseHttpDownloader {
-
- private static final String GET = "GET";
- private static final String HTTP_PROXY_USER = "http.proxyUser";
- private static final String HTTP_PROXY_PASSWORD = "http.proxyPassword";
-
- private static final List<String> PROXY_SETTINGS = ImmutableList.of(
- "http.proxyHost", "http.proxyPort", "http.nonProxyHosts",
- "http.auth.ntlm.domain", "socksProxyHost", "socksProxyPort");
-
- private String userAgent;
-
- public BaseHttpDownloader(Map<String, String> settings, @Nullable String userAgent) {
- initProxy(settings);
- initUserAgent(userAgent);
- }
-
- private void initProxy(Map<String, String> settings) {
- propagateProxySystemProperties(settings);
- if (requiresProxyAuthentication(settings)) {
- registerProxyCredentials(settings);
- }
- }
-
- private void initUserAgent(@Nullable String sonarVersion) {
- userAgent = (sonarVersion == null ? "SonarQube" : String.format("SonarQube %s", sonarVersion));
- System.setProperty("http.agent", userAgent);
- }
-
- private String getProxySynthesis(URI uri) {
- return getProxySynthesis(uri, ProxySelector.getDefault());
- }
-
- @VisibleForTesting
- static String getProxySynthesis(URI uri, ProxySelector proxySelector) {
- List<Proxy> proxies = proxySelector.select(uri);
- if (proxies.size() == 1 && proxies.get(0).type().equals(Proxy.Type.DIRECT)) {
- return "no proxy";
- }
-
- List<String> descriptions = Lists.newArrayList();
- for (Proxy proxy : proxies) {
- if (proxy.type() != Proxy.Type.DIRECT) {
- descriptions.add(proxy.type() + " proxy: " + proxy.address());
- }
- }
-
- return Joiner.on(", ").join(descriptions);
- }
-
- private void registerProxyCredentials(Map<String, String> settings) {
- Authenticator.setDefault(new ProxyAuthenticator(
- settings.get(HTTP_PROXY_USER),
- settings.get(HTTP_PROXY_PASSWORD)));
- }
-
- private boolean requiresProxyAuthentication(Map<String, String> settings) {
- return settings.containsKey(HTTP_PROXY_USER);
- }
-
- private void propagateProxySystemProperties(Map<String, String> settings) {
- for (String key : PROXY_SETTINGS) {
- if (settings.containsKey(key)) {
- System.setProperty(key, settings.get(key));
- }
- }
- }
-
- public InputSupplier<InputStream> newInputSupplier(URI uri) {
- return new HttpInputSupplier(uri, GET, userAgent, null, null, TIMEOUT_MILLISECONDS);
- }
-
- public InputSupplier<InputStream> newInputSupplier(URI uri, @Nullable Integer readTimeoutMillis) {
- return newInputSupplier(uri, GET, readTimeoutMillis);
- }
-
- public InputSupplier<InputStream> newInputSupplier(URI uri, String requestMethod, @Nullable Integer readTimeoutMillis) {
- if (readTimeoutMillis != null) {
- return new HttpInputSupplier(uri, requestMethod, userAgent, null, null, readTimeoutMillis);
- }
- return new HttpInputSupplier(uri, requestMethod, userAgent, null, null, TIMEOUT_MILLISECONDS);
- }
+public abstract class HttpDownloader extends UriReader.SchemeProcessor implements BatchComponent, ServerComponent {
+ public abstract String downloadPlainText(URI uri, String encoding);
- public InputSupplier<InputStream> newInputSupplier(URI uri, String login, String password) {
- return newInputSupplier(uri, GET, login, password);
- }
-
- /**
- * @since 5.0
- */
- public InputSupplier<InputStream> newInputSupplier(URI uri, String requestMethod, String login, String password) {
- return new HttpInputSupplier(uri, requestMethod, userAgent, login, password, TIMEOUT_MILLISECONDS);
- }
-
- public InputSupplier<InputStream> newInputSupplier(URI uri, String login, String password, @Nullable Integer readTimeoutMillis) {
- return newInputSupplier(uri, GET, login, password, readTimeoutMillis);
- }
-
- /**
- * @since 5.0
- */
- public InputSupplier<InputStream> newInputSupplier(URI uri, String requestMethod, String login, String password, @Nullable Integer readTimeoutMillis) {
- if (readTimeoutMillis != null) {
- return new HttpInputSupplier(uri, requestMethod, userAgent, login, password, readTimeoutMillis);
- }
- return new HttpInputSupplier(uri, requestMethod, userAgent, login, password, TIMEOUT_MILLISECONDS);
- }
-
- private static class HttpInputSupplier implements InputSupplier<InputStream> {
- private final String login;
- private final String password;
- private final URI uri;
- private final String userAgent;
- private final int readTimeoutMillis;
- private final String requestMethod;
-
- HttpInputSupplier(URI uri, String requestMethod, String userAgent, String login, String password, int readTimeoutMillis) {
- this.uri = uri;
- this.requestMethod = requestMethod;
- this.userAgent = userAgent;
- this.login = login;
- this.password = password;
- this.readTimeoutMillis = readTimeoutMillis;
- }
-
- @Override
- public InputStream getInput() throws IOException {
- Loggers.get(getClass()).debug("Download: " + uri + " (" + getProxySynthesis(uri, ProxySelector.getDefault()) + ")");
-
- HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
- connection.setRequestMethod(requestMethod);
- HttpsTrust.INSTANCE.trust(connection);
+ public abstract byte[] download(URI uri);
- // allow both GZip and Deflate (ZLib) encodings
- connection.setRequestProperty("Accept-Encoding", "gzip");
- if (!Strings.isNullOrEmpty(login)) {
- String encoded = Base64.encodeBase64String((login + ":" + password).getBytes(Charsets.UTF_8));
- connection.setRequestProperty("Authorization", "Basic " + encoded);
- }
- connection.setConnectTimeout(TIMEOUT_MILLISECONDS);
- connection.setReadTimeout(readTimeoutMillis);
- connection.setUseCaches(true);
- connection.setInstanceFollowRedirects(true);
- connection.setRequestProperty("User-Agent", userAgent);
+ public abstract InputStream openStream(URI uri);
- // establish connection, get response headers
- connection.connect();
-
- // obtain the encoding returned by the server
- String encoding = connection.getContentEncoding();
-
- int responseCode = connection.getResponseCode();
- if (responseCode >= 400) {
- InputStream errorResponse = null;
- try {
- errorResponse = connection.getErrorStream();
- if (errorResponse != null) {
- String errorResponseContent = IOUtils.toString(errorResponse);
- throw new HttpException(uri, responseCode, errorResponseContent);
- }
- throw new HttpException(uri, responseCode);
-
- } finally {
- IOUtils.closeQuietly(errorResponse);
- }
- }
-
- InputStream resultingInputStream;
- // create the appropriate stream wrapper based on the encoding type
- if (encoding != null && "gzip".equalsIgnoreCase(encoding)) {
- resultingInputStream = new GZIPInputStream(connection.getInputStream());
- } else {
- resultingInputStream = connection.getInputStream();
- }
- return resultingInputStream;
- }
- }
-
- private static class ProxyAuthenticator extends Authenticator {
- private final PasswordAuthentication auth;
-
- ProxyAuthenticator(String user, String password) {
- auth = new PasswordAuthentication(user, password == null ? new char[0] : password.toCharArray());
- }
-
- @Override
- protected PasswordAuthentication getPasswordAuthentication() {
- return auth;
- }
- }
- }
+ public abstract void download(URI uri, File toFile);
public static class HttpException extends RuntimeException {
private final URI uri;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpsTrust.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpsTrust.java
deleted file mode 100644
index 3ca747135d1..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/HttpsTrust.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * SonarQube, open source software quality management tool.
- * Copyright (C) 2008-2014 SonarSource
- * mailto:contact AT sonarsource DOT com
- *
- * SonarQube is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * SonarQube is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-package org.sonar.api.utils;
-
-import javax.net.ssl.*;
-import java.net.HttpURLConnection;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.security.cert.X509Certificate;
-
-/**
- * @since 4.0
- */
-class HttpsTrust {
-
- static HttpsTrust INSTANCE = new HttpsTrust(new Ssl());
-
- static class Ssl {
- SSLSocketFactory newFactory(TrustManager... managers) throws NoSuchAlgorithmException, KeyManagementException {
- SSLContext context = SSLContext.getInstance("TLS");
- context.init(null, managers, new SecureRandom());
- return context.getSocketFactory();
- }
- }
-
- private final SSLSocketFactory socketFactory;
- private final HostnameVerifier hostnameVerifier;
-
- HttpsTrust(Ssl context) {
- this.socketFactory = createSocketFactory(context);
- this.hostnameVerifier = createHostnameVerifier();
- }
-
- void trust(HttpURLConnection connection) {
- if (connection instanceof HttpsURLConnection) {
- HttpsURLConnection httpsConnection = (HttpsURLConnection) connection;
- httpsConnection.setSSLSocketFactory(socketFactory);
- httpsConnection.setHostnameVerifier(hostnameVerifier);
- }
- }
-
- /**
- * Trust all certificates
- */
- private SSLSocketFactory createSocketFactory(Ssl context) {
- try {
- return context.newFactory(new AlwaysTrustManager());
- } catch (Exception e) {
- throw new IllegalStateException("Fail to build SSL factory", e);
- }
- }
-
- /**
- * Trust all hosts
- */
- private HostnameVerifier createHostnameVerifier() {
- return new HostnameVerifier() {
- @Override
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- };
- }
-
- static class AlwaysTrustManager implements X509TrustManager {
- @Override
- public X509Certificate[] getAcceptedIssuers() {
- return new X509Certificate[0];
- }
-
- @Override
- public void checkClientTrusted(X509Certificate[] chain, String authType) {
- // Do not check
- }
-
- @Override
- public void checkServerTrusted(X509Certificate[] chain, String authType) {
- // Do not check
- }
- }
-}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java
index a5d001731aa..ad435de7b23 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/UriReader.java
@@ -86,14 +86,14 @@ public class UriReader implements BatchComponent, ServerComponent {
return processor;
}
- abstract static class SchemeProcessor {
- abstract String[] getSupportedSchemes();
+ public abstract static class SchemeProcessor {
+ protected abstract String[] getSupportedSchemes();
- abstract byte[] readBytes(URI uri);
+ protected abstract byte[] readBytes(URI uri);
- abstract String readString(URI uri, Charset charset);
+ protected abstract String readString(URI uri, Charset charset);
- abstract String description(URI uri);
+ protected abstract String description(URI uri);
}
@@ -108,7 +108,7 @@ public class UriReader implements BatchComponent, ServerComponent {
}
@Override
- byte[] readBytes(URI uri) {
+ protected byte[] readBytes(URI uri) {
try {
return Files.toByteArray(new File(uri));
} catch (IOException e) {
@@ -117,7 +117,7 @@ public class UriReader implements BatchComponent, ServerComponent {
}
@Override
- String readString(URI uri, Charset charset) {
+ protected String readString(URI uri, Charset charset) {
try {
return Files.toString(new File(uri), charset);
} catch (IOException e) {
@@ -126,7 +126,7 @@ public class UriReader implements BatchComponent, ServerComponent {
}
@Override
- String description(URI uri) {
+ protected String description(URI uri) {
return new File(uri).getAbsolutePath();
}
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/command/Command.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/command/Command.java
index c100a48cb54..7a14ba52e9e 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/command/Command.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/command/Command.java
@@ -23,12 +23,12 @@ import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.lang.StringUtils;
import org.sonar.api.utils.System2;
import java.io.File;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@@ -38,8 +38,8 @@ import java.util.Map;
*/
public class Command {
private final String executable;
- private final List<String> arguments = Lists.newArrayList();
- private final List<String> argumentsForLogs = Lists.newArrayList();
+ private final List<String> arguments = new ArrayList<>();
+ private final List<String> argumentsForLogs = new ArrayList<>();
private final Map<String, String> env;
private File directory;
private boolean newShell = false;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java
index 113991951a4..6cd3b683af9 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/dag/DirectAcyclicGraph.java
@@ -63,7 +63,7 @@ public class DirectAcyclicGraph {
public List sort() {
sortNodes();
- List<Object> result = Lists.newArrayList();
+ List<Object> result = new ArrayList<>();
for (Node node : nodes) {
result.add(node.getObject());
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/web/Filter.java b/sonar-plugin-api/src/main/java/org/sonar/api/web/Filter.java
index 784ed579ef7..0325360050c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/web/Filter.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/web/Filter.java
@@ -19,12 +19,11 @@
*/
package org.sonar.api.web;
-import com.google.common.collect.Lists;
+import com.google.common.base.Preconditions;
+import java.util.ArrayList;
import java.util.List;
-import com.google.common.base.Preconditions;
-
/**
* Definition of a filter.
*
@@ -44,8 +43,8 @@ public final class Filter {
private Filter() {
displayAs = LIST;
- criteria = Lists.newArrayList();
- columns = Lists.newArrayList();
+ criteria = new ArrayList<>();
+ columns = new ArrayList<>();
}
/**