From ffab6da42d0f27107d8cbdd3beb32c7e12595c53 Mon Sep 17 00:00:00 2001 From: uboness Date: Tue, 2 Feb 2016 20:57:05 +0100 Subject: [PATCH] fix build with latest core changes `Terminal.println(..)` doesn't support varargs arguments anymore Original commit: elastic/x-pack-elasticsearch@533a4f7919485ca7538a6da5daca2e5694f6c890 --- .../authc/esusers/tool/ESUsersTool.java | 30 +++++++++---------- .../shield/crypto/tool/SystemKeyTool.java | 6 ++-- .../ManualPublicSmtpServersTester.java | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/esusers/tool/ESUsersTool.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/esusers/tool/ESUsersTool.java index e77e54d477b..3587b4aad0a 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/esusers/tool/ESUsersTool.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/authc/esusers/tool/ESUsersTool.java @@ -160,7 +160,7 @@ public class ESUsersTool extends CliTool { Path file = FileUserPasswdStore.resolveFile(esusersSettings, env); Map users = new HashMap<>(FileUserPasswdStore.parseFile(file, null)); if (users.containsKey(username)) { - terminal.println("User [%s] already exists", username); + terminal.println(String.format("User [%s] already exists", username)); return ExitStatus.CODE_ERROR; } Hasher hasher = Hasher.BCRYPT; @@ -228,7 +228,7 @@ public class ESUsersTool extends CliTool { Path file = FileUserPasswdStore.resolveFile(esusersSettings, env); Map users = new HashMap<>(FileUserPasswdStore.parseFile(file, null)); if (!users.containsKey(username)) { - terminal.println("User [%s] doesn't exist", username); + terminal.println(String.format("User [%s] doesn't exist", username)); return ExitStatus.NO_USER; } @@ -308,7 +308,7 @@ public class ESUsersTool extends CliTool { Path file = FileUserPasswdStore.resolveFile(esusersSettings, env); Map users = new HashMap<>(FileUserPasswdStore.parseFile(file, null)); if (!users.containsKey(username)) { - terminal.println("User [%s] doesn't exist", username); + terminal.println(String.format("User [%s] doesn't exist", username)); return ExitStatus.NO_USER; } Hasher hasher = Hasher.BCRYPT; @@ -378,7 +378,7 @@ public class ESUsersTool extends CliTool { String[] allRoles = ArrayUtils.concat(addRoles, removeRoles, String.class); for (String role : allRoles) { if (!ROLE_PATTERN.matcher(role).matches()) { - terminal.println("Role name [%s] is not valid. Please use lowercase and numbers only", role); + terminal.println(String.format("Role name [%s] is not valid. Please use lowercase and numbers only", role)); return ExitStatus.DATA_ERROR; } } @@ -388,7 +388,7 @@ public class ESUsersTool extends CliTool { Path path = FileUserPasswdStore.resolveFile(esusersSettings, env); Map usersMap = FileUserPasswdStore.parseFile(path, null); if (!usersMap.containsKey(username)) { - terminal.println("User [%s] doesn't exist", username); + terminal.println(String.format("User [%s] doesn't exist", username)); return ExitStatus.NO_USER; } @@ -451,7 +451,7 @@ public class ESUsersTool extends CliTool { if (username != null) { if (!users.contains(username)) { - terminal.println("User [%s] doesn't exist", username); + terminal.println(String.format("User [%s] doesn't exist", username)); return ExitStatus.NO_USER; } @@ -459,15 +459,15 @@ public class ESUsersTool extends CliTool { String[] roles = userRoles.get(username); Set unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles); String[] markedRoles = markUnknownRoles(roles, unknownRoles); - terminal.println("%-15s: %s", username, Arrays.stream(markedRoles).map(s -> s == null ? "-" : s).collect(Collectors.joining(","))); + terminal.println(String.format("%-15s: %s", username, Arrays.stream(markedRoles).map(s -> s == null ? "-" : s).collect(Collectors.joining(",")))); if (!unknownRoles.isEmpty()) { // at least one role is marked... so printing the legend Path rolesFile = FileRolesStore.resolveFile(esusersSettings, env).toAbsolutePath(); terminal.println(); - terminal.println(" [*] An unknown role. Please check [%s] to see available roles", rolesFile.toAbsolutePath()); + terminal.println(String.format(" [*] An unknown role. Please check [%s] to see available roles", rolesFile.toAbsolutePath())); } } else { - terminal.println("%-15s: -", username); + terminal.println(String.format("%-15s: -", username)); } } else { boolean unknownRolesFound = false; @@ -476,7 +476,7 @@ public class ESUsersTool extends CliTool { String[] roles = entry.getValue(); Set unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles); String[] markedRoles = markUnknownRoles(roles, unknownRoles); - terminal.println("%-15s: %s", entry.getKey(), String.join(",", markedRoles)); + terminal.println(String.format("%-15s: %s", entry.getKey(), String.join(",", markedRoles))); unknownRolesFound = unknownRolesFound || !unknownRoles.isEmpty(); usersExist = true; } @@ -484,7 +484,7 @@ public class ESUsersTool extends CliTool { Set usersWithoutRoles = Sets.newHashSet(users); usersWithoutRoles.removeAll(userRoles.keySet()); for (String user : usersWithoutRoles) { - terminal.println("%-15s: -", user); + terminal.println(String.format("%-15s: -", user)); usersExist = true; } @@ -497,7 +497,7 @@ public class ESUsersTool extends CliTool { // at least one role is marked... so printing the legend Path rolesFile = FileRolesStore.resolveFile(esusersSettings, env).toAbsolutePath(); terminal.println(); - terminal.println(" [*] An unknown role. Please check [%s] to see available roles", rolesFile.toAbsolutePath()); + terminal.println(String.format(" [*] An unknown role. Please check [%s] to see available roles", rolesFile.toAbsolutePath())); } } @@ -511,7 +511,7 @@ public class ESUsersTool extends CliTool { return FileRolesStore.parseFileForRoleNames(rolesFile, null); } catch (Throwable t) { // if for some reason, parsing fails (malformatted perhaps) we just warn - terminal.println("Warning: Could not parse [%s] for roles verification. Please revise and fix it. Nonetheless, the user will still be associated with all specified roles", rolesFile.toAbsolutePath()); + terminal.println(String.format("Warning: Could not parse [%s] for roles verification. Please revise and fix it. Nonetheless, the user will still be associated with all specified roles", rolesFile.toAbsolutePath())); } return null; } @@ -536,9 +536,9 @@ public class ESUsersTool extends CliTool { Set unknownRoles = Sets.difference(Sets.newHashSet(roles), knownRoles); if (!unknownRoles.isEmpty()) { Path rolesFile = FileRolesStore.resolveFile(settings, env); - terminal.println("Warning: The following roles [%s] are unknown. Make sure to add them to the [%s] file. " + + terminal.println(String.format("Warning: The following roles [%s] are unknown. Make sure to add them to the [%s] file. " + "Nonetheless the user will still be associated with all specified roles", - Strings.collectionToCommaDelimitedString(unknownRoles), rolesFile.toAbsolutePath()); + Strings.collectionToCommaDelimitedString(unknownRoles), rolesFile.toAbsolutePath())); } } } diff --git a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/crypto/tool/SystemKeyTool.java b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/crypto/tool/SystemKeyTool.java index 3de4f60a55a..decf56baf24 100644 --- a/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/crypto/tool/SystemKeyTool.java +++ b/elasticsearch/x-pack/shield/src/main/java/org/elasticsearch/shield/crypto/tool/SystemKeyTool.java @@ -97,10 +97,10 @@ public class SystemKeyTool extends CliTool { } terminal.println(Terminal.Verbosity.VERBOSE, "generating..."); byte[] key = InternalCryptoService.generateKey(); - terminal.println("Storing generated key in [%s]...", path.toAbsolutePath()); + terminal.println(String.format("Storing generated key in [%s]...", path.toAbsolutePath())); Files.write(path, key, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } catch (IOException ioe) { - terminal.printError("Cannot generate and save system key file [%s]", path.toAbsolutePath()); + terminal.printError(String.format("Cannot generate and save system key file [%s]", path.toAbsolutePath())); return ExitStatus.IO_ERROR; } @@ -109,7 +109,7 @@ public class SystemKeyTool extends CliTool { try { Files.setPosixFilePermissions(path, PERMISSION_OWNER_READ_WRITE); } catch (IOException ioe) { - terminal.printError("Cannot set owner read/write permissions to generated system key file [%s]", path.toAbsolutePath()); + terminal.printError(String.format("Cannot set owner read/write permissions to generated system key file [%s]", path.toAbsolutePath())); return ExitStatus.IO_ERROR; } terminal.println("Ensure the generated key can be read by the user that Elasticsearch runs as, permissions are set to owner read/write only"); diff --git a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/email/service/ManualPublicSmtpServersTester.java b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/email/service/ManualPublicSmtpServersTester.java index 8b036e82b5a..6a277cf1032 100644 --- a/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/email/service/ManualPublicSmtpServersTester.java +++ b/elasticsearch/x-pack/watcher/src/test/java/org/elasticsearch/watcher/actions/email/service/ManualPublicSmtpServersTester.java @@ -121,7 +121,7 @@ public class ManualPublicSmtpServersTester { EmailService.EmailSent sent = service.send(email, null, profile); - terminal.println("email sent via account [%s]", sent.account()); + terminal.println(String.format("email sent via account [%s]", sent.account())); } finally { service.stop(); }