Merge pull request elastic/elasticsearch#650 from jasontedor/joiner-be-gone
Remove use of com.google.common.base.Joiner Original commit: elastic/x-pack-elasticsearch@fad27ff46b
This commit is contained in:
commit
8942e1e559
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.shield.authc.esusers.tool;
|
package org.elasticsearch.shield.authc.esusers.tool;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
|
@ -30,6 +29,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static org.elasticsearch.common.cli.CliToolConfig.Builder.cmd;
|
import static org.elasticsearch.common.cli.CliToolConfig.Builder.cmd;
|
||||||
import static org.elasticsearch.common.cli.CliToolConfig.Builder.option;
|
import static org.elasticsearch.common.cli.CliToolConfig.Builder.option;
|
||||||
|
@ -447,7 +447,7 @@ public class ESUsersTool extends CliTool {
|
||||||
String[] roles = userRoles.get(username);
|
String[] roles = userRoles.get(username);
|
||||||
Set<String> unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles);
|
Set<String> unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles);
|
||||||
String[] markedRoles = markUnknownRoles(roles, unknownRoles);
|
String[] markedRoles = markUnknownRoles(roles, unknownRoles);
|
||||||
terminal.println("%-15s: %s", username, Joiner.on(",").useForNull("-").join(markedRoles));
|
terminal.println("%-15s: %s", username, Arrays.stream(markedRoles).map(s -> s == null ? "-" : s).collect(Collectors.joining(",")));
|
||||||
if (!unknownRoles.isEmpty()) {
|
if (!unknownRoles.isEmpty()) {
|
||||||
// at least one role is marked... so printing the legend
|
// at least one role is marked... so printing the legend
|
||||||
Path rolesFile = FileRolesStore.resolveFile(esusersSettings, env).toAbsolutePath();
|
Path rolesFile = FileRolesStore.resolveFile(esusersSettings, env).toAbsolutePath();
|
||||||
|
@ -464,7 +464,7 @@ public class ESUsersTool extends CliTool {
|
||||||
String[] roles = entry.getValue();
|
String[] roles = entry.getValue();
|
||||||
Set<String> unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles);
|
Set<String> unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles);
|
||||||
String[] markedRoles = markUnknownRoles(roles, unknownRoles);
|
String[] markedRoles = markUnknownRoles(roles, unknownRoles);
|
||||||
terminal.println("%-15s: %s", entry.getKey(), Joiner.on(",").join(markedRoles));
|
terminal.println("%-15s: %s", entry.getKey(), String.join(",", markedRoles));
|
||||||
unknownRolesFound = unknownRolesFound || !unknownRoles.isEmpty();
|
unknownRolesFound = unknownRolesFound || !unknownRoles.isEmpty();
|
||||||
usersExist = true;
|
usersExist = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.integration;
|
package org.elasticsearch.integration;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import org.apache.http.impl.client.CloseableHttpClient;
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
import org.apache.http.impl.client.HttpClients;
|
import org.apache.http.impl.client.HttpClients;
|
||||||
import org.elasticsearch.action.ActionListener;
|
import org.elasticsearch.action.ActionListener;
|
||||||
|
@ -123,7 +122,7 @@ public class ClearRealmsCacheTests extends ShieldIntegTestCase {
|
||||||
@Override
|
@Override
|
||||||
public void executeRequest() throws Exception {
|
public void executeRequest() throws Exception {
|
||||||
String path = "/_shield/realm/" + (randomBoolean() ? "*" : "_all") + "/_cache/clear";
|
String path = "/_shield/realm/" + (randomBoolean() ? "*" : "_all") + "/_cache/clear";
|
||||||
Map<String, String> params = Collections.singletonMap("usernames", Joiner.on(',').join(evicted_usernames));
|
Map<String, String> params = Collections.singletonMap("usernames", String.join(",", evicted_usernames));
|
||||||
executeHttpRequest(path, params);
|
executeHttpRequest(path, params);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.watcher.trigger.schedule.support;
|
package org.elasticsearch.watcher.trigger.schedule.support;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
import org.elasticsearch.common.ParseFieldMatcher;
|
||||||
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
|
||||||
|
@ -100,7 +100,12 @@ public class MonthTimes implements Times {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "days [" + Ints.join(",", days) + "], times [" + Joiner.on(",").join(times) + "]";
|
return String.format(
|
||||||
|
Locale.ROOT,
|
||||||
|
"days [%s], times [%s]",
|
||||||
|
Ints.join(",", days),
|
||||||
|
Strings.arrayToCommaDelimitedString(times)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean contains(int day, DayTimes dayTimes) {
|
public boolean contains(int day, DayTimes dayTimes) {
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.watcher.trigger.schedule.support;
|
package org.elasticsearch.watcher.trigger.schedule.support;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
import org.elasticsearch.common.ParseFieldMatcher;
|
||||||
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ public class YearTimes implements Times {
|
||||||
String minsStr = Ints.join(",", times.minute);
|
String minsStr = Ints.join(",", times.minute);
|
||||||
String daysStr = Ints.join(",", this.days);
|
String daysStr = Ints.join(",", this.days);
|
||||||
daysStr = daysStr.replace("32", "L");
|
daysStr = daysStr.replace("32", "L");
|
||||||
String monthsStr = Joiner.on(",").join(months);
|
String monthsStr = Strings.collectionToCommaDelimitedString(months);
|
||||||
String expression = "0 " + minsStr + " " + hrsStr + " " + daysStr + " " + monthsStr + " ?";
|
String expression = "0 " + minsStr + " " + hrsStr + " " + daysStr + " " + monthsStr + " ?";
|
||||||
crons.add(expression);
|
crons.add(expression);
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,13 @@ public class YearTimes implements Times {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "months [" + Joiner.on(",").join(months) + "], days [" + Ints.join(",", days) + "], times [" + Joiner.on(",").join(times) + "]";
|
return String.format(
|
||||||
|
Locale.ROOT,
|
||||||
|
"months [%s], days [%s], times [%s]",
|
||||||
|
Strings.collectionToCommaDelimitedString(months),
|
||||||
|
Ints.join(",", days),
|
||||||
|
Strings.arrayToCommaDelimitedString(times)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
package org.elasticsearch.watcher.trigger.schedule;
|
package org.elasticsearch.watcher.trigger.schedule;
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -41,7 +41,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
||||||
String[] crons = expressions(schedule);
|
String[] crons = expressions(schedule);
|
||||||
assertThat(crons, arrayWithSize(time.times().length));
|
assertThat(crons, arrayWithSize(time.times().length));
|
||||||
for (DayTimes dayTimes : time.times()) {
|
for (DayTimes dayTimes : time.times()) {
|
||||||
assertThat(crons, hasItemInArray("0 " + Ints.join(",", dayTimes.minute()) + " " + Ints.join(",", dayTimes.hour()) + " ? * " + Joiner.on(",").join(time.days())));
|
assertThat(crons, hasItemInArray("0 " + Ints.join(",", dayTimes.minute()) + " " + Ints.join(",", dayTimes.hour()) + " ? * " + Strings.collectionToCommaDelimitedString(time.days())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class WeeklyScheduleTests extends ScheduleTestCase {
|
||||||
assertThat(crons, arrayWithSize(count));
|
assertThat(crons, arrayWithSize(count));
|
||||||
for (WeekTimes weekTimes : times) {
|
for (WeekTimes weekTimes : times) {
|
||||||
for (DayTimes dayTimes : weekTimes.times()) {
|
for (DayTimes dayTimes : weekTimes.times()) {
|
||||||
assertThat(crons, hasItemInArray("0 " + Ints.join(",", dayTimes.minute()) + " " + Ints.join(",", dayTimes.hour()) + " ? * " + Joiner.on(",").join(weekTimes.days())));
|
assertThat(crons, hasItemInArray("0 " + Ints.join(",", dayTimes.minute()) + " " + Ints.join(",", dayTimes.hour()) + " ? * " + Strings.collectionToCommaDelimitedString(weekTimes.days())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
package org.elasticsearch.watcher.trigger.schedule;
|
package org.elasticsearch.watcher.trigger.schedule;
|
||||||
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import com.google.common.primitives.Ints;
|
import com.google.common.primitives.Ints;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -44,7 +44,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
||||||
String hrStr = Ints.join(",", dayTimes.hour());
|
String hrStr = Ints.join(",", dayTimes.hour());
|
||||||
String dayStr = Ints.join(",", time.days());
|
String dayStr = Ints.join(",", time.days());
|
||||||
dayStr = dayStr.replace("32", "L");
|
dayStr = dayStr.replace("32", "L");
|
||||||
String monthStr = Joiner.on(",").join(time.months());
|
String monthStr = Strings.collectionToCommaDelimitedString(time.months());
|
||||||
String expression = "0 " + minStr + " " + hrStr + " " + dayStr + " " + monthStr + " ?";
|
String expression = "0 " + minStr + " " + hrStr + " " + dayStr + " " + monthStr + " ?";
|
||||||
logger.info("expression: " + expression);
|
logger.info("expression: " + expression);
|
||||||
assertThat(crons, hasItemInArray(expression));
|
assertThat(crons, hasItemInArray(expression));
|
||||||
|
@ -67,7 +67,7 @@ public class YearlyScheduleTests extends ScheduleTestCase {
|
||||||
String hrStr = Ints.join(",", dayTimes.hour());
|
String hrStr = Ints.join(",", dayTimes.hour());
|
||||||
String dayStr = Ints.join(",", yearTimes.days());
|
String dayStr = Ints.join(",", yearTimes.days());
|
||||||
dayStr = dayStr.replace("32", "L");
|
dayStr = dayStr.replace("32", "L");
|
||||||
String monthStr = Joiner.on(",").join(yearTimes.months());
|
String monthStr = Strings.collectionToCommaDelimitedString(yearTimes.months());
|
||||||
assertThat(crons, hasItemInArray("0 " + minStr + " " + hrStr + " " + dayStr + " " + monthStr + " ?"));
|
assertThat(crons, hasItemInArray("0 " + minStr + " " + hrStr + " " + dayStr + " " + monthStr + " ?"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue