@@ -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) { |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; |
@@ -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; |
@@ -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) { |
@@ -24,7 +24,7 @@ import com.google.common.base.Joiner; | |||
import com.google.common.base.Objects; | |||
import com.google.common.base.Predicate; | |||
import com.google.common.collect.Collections2; | |||
import org.apache.commons.collections.CollectionUtils; | |||
import com.google.common.collect.Sets; | |||
import org.apache.commons.lang.StringUtils; | |||
import org.apache.commons.lang.time.DateUtils; | |||
import org.sonar.api.BatchComponent; | |||
@@ -42,6 +42,7 @@ import javax.annotation.Nullable; | |||
import java.util.Calendar; | |||
import java.util.Collection; | |||
import java.util.Date; | |||
import java.util.Set; | |||
/** | |||
* Updates issue fields and chooses if changes must be kept in history. | |||
@@ -274,7 +275,7 @@ public class IssueUpdater implements BatchComponent, ServerComponent { | |||
} | |||
public boolean setTags(DefaultIssue issue, Collection<String> tags, IssueChangeContext context) { | |||
Collection<String> newTags = Collections2.transform( | |||
Set<String> newTags = Sets.newHashSet(Collections2.transform( | |||
Collections2.filter(tags, new Predicate<String>() { | |||
@Override | |||
public boolean apply(String tag) { | |||
@@ -287,10 +288,11 @@ public class IssueUpdater implements BatchComponent, ServerComponent { | |||
RuleTagFormat.validate(lowerCaseTag); | |||
return lowerCaseTag; | |||
} | |||
}); | |||
})); | |||
Collection<String> oldTags = issue.tags(); | |||
if (!CollectionUtils.isEqualCollection(oldTags, newTags)) { | |||
Set<String> oldTags = Sets.newHashSet(issue.tags()); | |||
if (!oldTags.equals(newTags)) { | |||
issue.setFieldChange(context, TAGS, | |||
oldTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(oldTags), | |||
newTags.isEmpty() ? null : CHANGELOG_TAG_JOINER.join(newTags)); |