aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2015-04-28 11:40:41 +0200
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2015-04-28 11:40:41 +0200
commit2a0b90ac049f9bfca1c18b25eeb2146ebe09bf76 (patch)
treee6fa3c200de8bd03377c3e7720e36c8b9818772b /server
parent244a9a026b9f236fc2b155e139b109cf279c0b8e (diff)
downloadsonarqube-2a0b90ac049f9bfca1c18b25eeb2146ebe09bf76.tar.gz
sonarqube-2a0b90ac049f9bfca1c18b25eeb2146ebe09bf76.zip
Fix quality flaws
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java12
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/AddTagsAction.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/issue/RemoveTagsAction.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileExportAction.java3
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java4
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java20
6 files changed, 33 insertions, 22 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java
index c2a045f5d37..a08faf89771 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentService.java
@@ -24,7 +24,6 @@ import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.Collections2;
import com.google.common.collect.Sets;
-import org.apache.commons.collections.CollectionUtils;
import org.sonar.api.ServerComponent;
import org.sonar.api.i18n.I18n;
import org.sonar.api.resources.Scopes;
@@ -45,7 +44,12 @@ import org.sonar.server.user.UserSession;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
-import java.util.*;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
import static com.google.common.collect.Lists.newArrayList;
@@ -202,8 +206,10 @@ public class ComponentService implements ServerComponent {
return component.key();
}
});
+ Set<String> missingKeys = Sets.newHashSet(componentKeys);
+ missingKeys.removeAll(foundKeys);
throw new NotFoundException("The following component keys do not match any component:\n" +
- Joiner.on('\n').join(CollectionUtils.subtract(componentKeys, foundKeys)));
+ Joiner.on('\n').join(missingKeys));
}
for (ComponentDto component : components) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/AddTagsAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/AddTagsAction.java
index 40114339c23..1214af8df69 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/AddTagsAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/AddTagsAction.java
@@ -20,11 +20,12 @@
package org.sonar.server.issue;
-import org.apache.commons.collections.CollectionUtils;
+import com.google.common.collect.Sets;
import org.sonar.api.ServerComponent;
import org.sonar.core.issue.IssueUpdater;
import java.util.Collection;
+import java.util.Set;
public class AddTagsAction extends AbstractChangeTagsAction implements ServerComponent {
@@ -36,8 +37,9 @@ public class AddTagsAction extends AbstractChangeTagsAction implements ServerCom
}
@Override
- @SuppressWarnings("unchecked")
protected Collection<String> getTagsToSet(Context context, Collection<String> tagsFromParams) {
- return CollectionUtils.union(context.issue().tags(), tagsFromParams);
+ Set<String> allTags = Sets.newHashSet(context.issue().tags());
+ allTags.addAll(tagsFromParams);
+ return allTags;
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/RemoveTagsAction.java b/server/sonar-server/src/main/java/org/sonar/server/issue/RemoveTagsAction.java
index 3a0c917eff1..2ab7d109861 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/issue/RemoveTagsAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/issue/RemoveTagsAction.java
@@ -20,11 +20,12 @@
package org.sonar.server.issue;
-import org.apache.commons.collections.CollectionUtils;
+import com.google.common.collect.Sets;
import org.sonar.api.ServerComponent;
import org.sonar.core.issue.IssueUpdater;
import java.util.Collection;
+import java.util.Set;
public class RemoveTagsAction extends AbstractChangeTagsAction implements ServerComponent {
@@ -36,8 +37,9 @@ public class RemoveTagsAction extends AbstractChangeTagsAction implements Server
}
@Override
- @SuppressWarnings("unchecked")
protected Collection<String> getTagsToSet(Context context, Collection<String> tagsFromParams) {
- return CollectionUtils.subtract(context.issue().tags(), tagsFromParams);
+ Set<String> newTags = Sets.newHashSet(context.issue().tags());
+ newTags.removeAll(tagsFromParams);
+ return newTags;
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileExportAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileExportAction.java
index 5d357905b59..992b9a8c5fb 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileExportAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/qualityprofile/ws/QProfileExportAction.java
@@ -19,6 +19,7 @@
*/
package org.sonar.server.qualityprofile.ws;
+import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import org.apache.commons.io.IOUtils;
import org.sonar.api.profiles.ProfileExporter;
@@ -110,7 +111,7 @@ public class QProfileExportAction implements BaseQProfileWsAction {
DbSession dbSession = dbClient.openSession(false);
Stream stream = response.stream();
OutputStream output = stream.output();
- Writer writer = new OutputStreamWriter(output);
+ Writer writer = new OutputStreamWriter(output, Charsets.UTF_8);
try {
QualityProfileDto profile = null;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java
index 307f1c30b6d..d3bd0835ec9 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/rule/ws/AppAction.java
@@ -22,7 +22,7 @@ package org.sonar.server.rule.ws;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
-import org.apache.commons.collections.ComparatorUtils;
+import org.apache.commons.lang.builder.CompareToBuilder;
import org.sonar.api.i18n.I18n;
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
@@ -161,7 +161,7 @@ public class AppAction implements RulesAction {
Collections.sort(rootCharacs, new Comparator<DebtCharacteristic>() {
@Override
public int compare(DebtCharacteristic o1, DebtCharacteristic o2) {
- return ComparatorUtils.nullHighComparator(ComparatorUtils.naturalComparator()).compare(o1.order(), o2.order());
+ return new CompareToBuilder().append(o1.order(), o2.order()).toComparison();
}
});
return rootCharacs;
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
index 448da1e0a14..98affe47f98 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/ui/ws/ComponentNavigationAction.java
@@ -223,16 +223,16 @@ public class ComponentNavigationAction implements NavigationAction {
private void writeConfigPageAccess(JsonWriter json, boolean isAdmin, ComponentDto component, UserSession userSession) {
boolean isProject = Qualifiers.PROJECT.equals(component.qualifier());
- json.prop("showSettings", isAdmin && componentTypeHasProperty(component, PROPERTY_CONFIGURABLE))
- .prop("showQualityProfiles", isProject)
- .prop("showQualityGates", isProject)
- .prop("showManualMeasures", isAdmin)
- .prop("showActionPlans", isAdmin && isProject)
- .prop("showLinks", isAdmin && isProject)
- .prop("showPermissions", isAdmin && componentTypeHasProperty(component, PROPERTY_HAS_ROLE_POLICY))
- .prop("showHistory", isAdmin && componentTypeHasProperty(component, PROPERTY_MODIFIABLE_HISTORY))
- .prop("showUpdateKey", isAdmin && componentTypeHasProperty(component, PROPERTY_UPDATABLE_KEY))
- .prop("showDeletion", isAdmin && componentTypeHasProperty(component, PROPERTY_DELETABLE));
+ json.prop("showSettings", isAdmin && componentTypeHasProperty(component, PROPERTY_CONFIGURABLE));
+ json.prop("showQualityProfiles", isProject);
+ json.prop("showQualityGates", isProject);
+ json.prop("showManualMeasures", isAdmin);
+ json.prop("showActionPlans", isAdmin && isProject);
+ json.prop("showLinks", isAdmin && isProject);
+ json.prop("showPermissions", isAdmin && componentTypeHasProperty(component, PROPERTY_HAS_ROLE_POLICY));
+ json.prop("showHistory", isAdmin && componentTypeHasProperty(component, PROPERTY_MODIFIABLE_HISTORY));
+ json.prop("showUpdateKey", isAdmin && componentTypeHasProperty(component, PROPERTY_UPDATABLE_KEY));
+ json.prop("showDeletion", isAdmin && componentTypeHasProperty(component, PROPERTY_DELETABLE));
}
private boolean componentTypeHasProperty(ComponentDto component, String resourceTypeProperty) {