Format Java files with google-java-format 1.6
Change-Id: Iedbc48f3cef2bf29245c79c986aa44ea39f3f1b0
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/GetFullPathCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/GetFullPathCommand.java
index 5dcbed0..4052f42 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/GetFullPathCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/GetFullPathCommand.java
@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-
package com.googlesource.gerrit.plugins.adminconsole;
import static com.google.gerrit.sshd.CommandMetaData.Mode.MASTER_OR_SLAVE;
@@ -21,18 +20,20 @@
import com.google.gerrit.extensions.annotations.CapabilityScope;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.server.git.GitRepositoryManager;
+import com.google.gerrit.server.git.LocalDiskRepositoryManager;
+import com.google.gerrit.server.project.ProjectCache;
import com.google.gerrit.sshd.CommandMetaData;
import com.google.gerrit.sshd.SshCommand;
-import com.google.gerrit.server.git.LocalDiskRepositoryManager;
-import com.google.gerrit.server.git.GitRepositoryManager;
-import com.google.gerrit.server.project.ProjectCache;
import com.google.inject.Inject;
-
import org.eclipse.jgit.lib.Constants;
import org.kohsuke.args4j.Argument;
@RequiresCapability(value = GlobalCapability.ADMINISTRATE_SERVER, scope = CapabilityScope.CORE)
-@CommandMetaData(runsAt = MASTER_OR_SLAVE, name = "get-path", description = "Gets the full path of a repository")
+@CommandMetaData(
+ runsAt = MASTER_OR_SLAVE,
+ name = "get-path",
+ description = "Gets the full path of a repository")
public final class GetFullPathCommand extends SshCommand {
@Argument(index = 0, required = true, metaVar = "PROJECT", usage = "Name of the project")
@@ -52,13 +53,14 @@
@Override
protected void run() throws UnloggedFailure {
if (localDiskRepositoryManager == null) {
- throw new UnloggedFailure(1,
- "Command only works with disk based repository managers");
+ throw new UnloggedFailure(1, "Command only works with disk based repository managers");
}
Project.NameKey nameKey = new Project.NameKey(projectName);
if (projectCache.get(nameKey) != null) {
- stdout.println(localDiskRepositoryManager.getBasePath(nameKey)
- .resolve(nameKey.get().concat(Constants.DOT_GIT_EXT)));
+ stdout.println(
+ localDiskRepositoryManager
+ .getBasePath(nameKey)
+ .resolve(nameKey.get().concat(Constants.DOT_GIT_EXT)));
} else {
throw new UnloggedFailure(1, "Repository not found");
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ListUsersCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ListUsersCommand.java
index 8ead5ad..926db63 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ListUsersCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ListUsersCommand.java
@@ -26,10 +26,9 @@
import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.ResultSet;
import com.google.inject.Inject;
-
import org.kohsuke.args4j.Option;
-@RequiresCapability(value=GlobalCapability.ADMINISTRATE_SERVER, scope=CapabilityScope.CORE)
+@RequiresCapability(value = GlobalCapability.ADMINISTRATE_SERVER, scope = CapabilityScope.CORE)
@CommandMetaData(name = "ls-users", description = "List users")
public final class ListUsersCommand extends SshCommand {
private ReviewDb db;
@@ -42,8 +41,7 @@
private boolean inactiveOnly = false;
@Inject
- ListUsersCommand(ReviewDb db,
- AccountResolver accountResolver) {
+ ListUsersCommand(ReviewDb db, AccountResolver accountResolver) {
this.db = db;
this.accountResolver = accountResolver;
}
@@ -59,25 +57,22 @@
continue;
}
String username = getUsername(account);
- String out = new StringBuilder()
- .append(account.getId().toString())
- .append(" |")
- .append(Strings.isNullOrEmpty(username)
- ? ""
- : " " + username)
- .append(" |")
- .append(Strings.isNullOrEmpty(account.getFullName())
- ? ""
- : " " + account.getFullName())
- .append(" |")
- .append(Strings.isNullOrEmpty(account.getPreferredEmail())
- ? ""
- : " " + account.getPreferredEmail())
- .append(" |")
- .append(account.isActive()
- ? " active"
- : " inactive")
- .toString();
+ String out =
+ new StringBuilder()
+ .append(account.getId().toString())
+ .append(" |")
+ .append(Strings.isNullOrEmpty(username) ? "" : " " + username)
+ .append(" |")
+ .append(
+ Strings.isNullOrEmpty(account.getFullName()) ? "" : " " + account.getFullName())
+ .append(" |")
+ .append(
+ Strings.isNullOrEmpty(account.getPreferredEmail())
+ ? ""
+ : " " + account.getPreferredEmail())
+ .append(" |")
+ .append(account.isActive() ? " active" : " inactive")
+ .toString();
stdout.println(out);
}
}
@@ -85,7 +80,6 @@
private String getUsername(Account account) throws OrmException {
String id = account.getId().toString();
Account accountFromResolver = accountResolver.find(db, id);
- return accountFromResolver == null ? null
- : accountFromResolver.getUserName();
+ return accountFromResolver == null ? null : accountFromResolver.getUserName();
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java
index 5c439ff..aa086f0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowAccountCommand.java
@@ -35,22 +35,22 @@
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
import com.google.inject.Provider;
-
-import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.kohsuke.args4j.Argument;
-import org.kohsuke.args4j.Option;
-
import java.io.IOException;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
+import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.kohsuke.args4j.Argument;
+import org.kohsuke.args4j.Option;
-@RequiresCapability(value=GlobalCapability.ADMINISTRATE_SERVER, scope=CapabilityScope.CORE)
+@RequiresCapability(value = GlobalCapability.ADMINISTRATE_SERVER, scope = CapabilityScope.CORE)
@CommandMetaData(name = "show-account", description = "Displays user information")
public final class ShowAccountCommand extends SshCommand {
- @Argument(usage = "User information to find: LastName,\\ Firstname, email@address.com, account id or an user name. Be sure to double-escape spaces, for example: \"show-account Last,\\\\ First\"")
+ @Argument(
+ usage =
+ "User information to find: LastName,\\ Firstname, email@address.com, account id or an user name. Be sure to double-escape spaces, for example: \"show-account Last,\\\\ First\"")
private String name = "";
@Option(name = "--show-groups", usage = "show group membership by user?")
@@ -69,7 +69,8 @@
private final Provider<GetSshKeys> getSshKeys;
@Inject
- ShowAccountCommand(AccountResolver accountResolver,
+ ShowAccountCommand(
+ AccountResolver accountResolver,
Provider<GetGroups> accountGetGroups,
IdentifiedUser.GenericFactory userFactory,
Provider<GetSshKeys> getSshKeys,
@@ -86,21 +87,29 @@
Account account;
if (name.isEmpty()) {
- throw new UnloggedFailure(1,
+ throw new UnloggedFailure(
+ 1,
"You need to tell me who to find: LastName,\\\\ Firstname, email@address.com, account id or an user name. "
+ "Be sure to double-escape spaces, for example: \"show-account Last,\\\\ First\"");
}
try (ReviewDb db = schema.open()) {
Set<Id> idList = accountResolver.findAll(db, name);
if (idList.isEmpty()) {
- throw new UnloggedFailure(1,
+ throw new UnloggedFailure(
+ 1,
"No accounts found for your query: \""
+ name
+ "\""
+ " Tip: Try double-escaping spaces, for example: \"show-account Last,\\\\ First\"");
}
- stdout.println("Found " + idList.size() + " result"
- + (idList.size() > 1 ? "s" : "") + ": for query: \"" + name + "\"");
+ stdout.println(
+ "Found "
+ + idList.size()
+ + " result"
+ + (idList.size() > 1 ? "s" : "")
+ + ": for query: \""
+ + name
+ + "\"");
stdout.println();
for (Id id : idList) {
@@ -115,17 +124,18 @@
stdout.println("Active: " + account.isActive());
stdout.println("Registered on: " + account.getRegisteredOn());
-
stdout.println("");
stdout.println("External Ids:");
- stdout.println(String
- .format("%-50s %s", "Email Address:", "External Id:"));
- for (AccountExternalId accountExternalId : db.accountExternalIds()
- .byAccount(account.getId())) {
- stdout.println(String.format("%-50s %s",
- (accountExternalId.getEmailAddress() == null ? ""
- : accountExternalId.getEmailAddress()), accountExternalId
- .getExternalId()));
+ stdout.println(String.format("%-50s %s", "Email Address:", "External Id:"));
+ for (AccountExternalId accountExternalId :
+ db.accountExternalIds().byAccount(account.getId())) {
+ stdout.println(
+ String.format(
+ "%-50s %s",
+ (accountExternalId.getEmailAddress() == null
+ ? ""
+ : accountExternalId.getEmailAddress()),
+ accountExternalId.getExternalId()));
}
if (showKeys) {
@@ -133,8 +143,7 @@
stdout.println("Public Keys:");
List<SshKeyInfo> sshKeys;
try {
- sshKeys = getSshKeys.get()
- .apply(new AccountResource(userFactory.create(id)));
+ sshKeys = getSshKeys.get().apply(new AccountResource(userFactory.create(id)));
} catch (AuthException | IOException | ConfigInvalidException e) {
throw new UnloggedFailure(1, "Error getting sshkeys: " + e.getMessage(), e);
}
@@ -143,25 +152,26 @@
} else {
stdout.println(String.format("%-9s %s", "Status:", "Key:"));
for (SshKeyInfo sshKey : sshKeys) {
- stdout.println(String.format("%-9s %s", (sshKey.valid
- ? "Active" : "Inactive"), sshKey.sshPublicKey));
+ stdout.println(
+ String.format(
+ "%-9s %s", (sshKey.valid ? "Active" : "Inactive"), sshKey.sshPublicKey));
}
}
}
if (showGroups) {
stdout.println();
- stdout.println("Member of groups"
- + (filterGroups == null ? "" : " (Filtering on \"" + filterGroups
- + "\")") + ":");
+ stdout.println(
+ "Member of groups"
+ + (filterGroups == null ? "" : " (Filtering on \"" + filterGroups + "\")")
+ + ":");
List<GroupInfo> groupInfos =
- accountGetGroups.get().apply(
- new AccountResource(userFactory.create(id)));
+ accountGetGroups.get().apply(new AccountResource(userFactory.create(id)));
Collections.sort(groupInfos, new CustomComparator());
for (GroupInfo groupInfo : groupInfos) {
- if (null == filterGroups || groupInfo.name.toLowerCase().contains(filterGroups.toLowerCase
- ())) {
+ if (null == filterGroups
+ || groupInfo.name.toLowerCase().contains(filterGroups.toLowerCase())) {
stdout.println(groupInfo.name);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java
index 1252b23..130e69c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java
@@ -26,16 +26,16 @@
import com.google.gerrit.sshd.CommandMetaData;
import com.google.gerrit.sshd.SshCommand;
import com.google.inject.Inject;
-
+import java.io.IOException;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
-import java.io.IOException;
-
-@RequiresCapability(value=GlobalCapability.ADMINISTRATE_SERVER, scope=CapabilityScope.CORE)
-@CommandMetaData(name = "show-repo-access", description = "Displays access on a specific repository")
+@RequiresCapability(value = GlobalCapability.ADMINISTRATE_SERVER, scope = CapabilityScope.CORE)
+@CommandMetaData(
+ name = "show-repo-access",
+ description = "Displays access on a specific repository")
public final class ShowRepoAccessCommand extends SshCommand {
@Argument(usage = "project to show access for?")
@@ -55,8 +55,7 @@
private int permissionGroupWidth;
@Override
- public void run() throws UnloggedFailure, Failure, IOException,
- ConfigInvalidException {
+ public void run() throws UnloggedFailure, Failure, IOException, ConfigInvalidException {
// space indented Strings to be used as format for String.format() later
String sectionNameFormatter = " %-25s\n";
String ruleNameFormatter = " %-15s\n ";
@@ -75,19 +74,20 @@
config = ProjectConfig.read(md);
for (AccessSection accessSection : config.getAccessSections()) {
- stdout.print((String.format(sectionNameFormatter, accessSection
- .getName().toString())));
+ stdout.print((String.format(sectionNameFormatter, accessSection.getName().toString())));
for (Permission permission : accessSection.getPermissions()) {
for (PermissionRule rule : permission.getRules()) {
- stdout
- .print(String.format(ruleNameFormatter, permission.getName()));
- stdout.print(String.format(permissionNameFormatter,
- (!rule.getMin().equals(rule.getMax())) ? "" + rule.getMin() + " "
- + rule.getMax() : rule.getAction(),
- (permission.getExclusiveGroup() ? "EXCLUSIVE" : ""),
- format(rule.getGroup().getName())));
+ stdout.print(String.format(ruleNameFormatter, permission.getName()));
+ stdout.print(
+ String.format(
+ permissionNameFormatter,
+ (!rule.getMin().equals(rule.getMax()))
+ ? "" + rule.getMin() + " " + rule.getMax()
+ : rule.getAction(),
+ (permission.getExclusiveGroup() ? "EXCLUSIVE" : ""),
+ format(rule.getGroup().getName())));
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java
index e80f81b..dca6eb9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccountAccessCommand.java
@@ -23,8 +23,8 @@
import com.google.gerrit.extensions.common.GroupInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Account.Id;
-import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResolver;
import com.google.gerrit.server.account.AccountResource;
@@ -36,24 +36,27 @@
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
import com.google.inject.Provider;
-
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import org.eclipse.jgit.errors.RepositoryNotFoundException;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-@RequiresCapability(value=GlobalCapability.ADMINISTRATE_SERVER, scope=CapabilityScope.CORE)
-@CommandMetaData(name = "show-repo-account-access", description = "Displays user's access on a specific repository")
+@RequiresCapability(value = GlobalCapability.ADMINISTRATE_SERVER, scope = CapabilityScope.CORE)
+@CommandMetaData(
+ name = "show-repo-account-access",
+ description = "Displays user's access on a specific repository")
public final class ShowRepoAccountAccessCommand extends SshCommand {
@Argument(usage = "project to show access for?")
private String projectName = "";
- @Option(name = "--user", usage = "User information to find: LastName,\\ Firstname, email@address.com, account id or an user name. "
- + "Be sure to double-escape spaces, for example: \"show-repo-account-access All-Projects --user Last,\\\\ First\"")
+ @Option(
+ name = "--user",
+ usage =
+ "User information to find: LastName,\\ Firstname, email@address.com, account id or an user name. "
+ + "Be sure to double-escape spaces, for example: \"show-repo-account-access All-Projects --user Last,\\\\ First\"")
private String name = "";
@Option(name = "-w", usage = "display without line width truncation")
@@ -96,14 +99,16 @@
}
if (name.isEmpty()) {
- throw new UnloggedFailure(1,
+ throw new UnloggedFailure(
+ 1,
"You need to tell me who to find: LastName,\\\\ Firstname, email@address.com, account id or an user name. "
+ "Be sure to double-escape spaces, for example: \"show-repo-account-access All-Projects --user Last,\\\\ First\"");
}
try (ReviewDb db = schema.open()) {
Set<Id> idList = accountResolver.findAll(db, name);
if (idList.isEmpty()) {
- throw new UnloggedFailure(1,
+ throw new UnloggedFailure(
+ 1,
"No accounts found for your query: \""
+ name
+ "\""
@@ -126,8 +131,7 @@
// Need to know what groups the user is in. This is not a great
// solution, but it does work.
List<GroupInfo> groupInfos =
- accountGetGroups.get().apply(
- new AccountResource(userFactory.create(id)));
+ accountGetGroups.get().apply(new AccountResource(userFactory.create(id)));
HashSet<String> groupHash = new HashSet<>();
for (GroupInfo groupInfo : groupInfos) {
@@ -136,8 +140,7 @@
for (AccessSection accessSection : config.getAccessSections()) {
StringBuilder sb = new StringBuilder();
- sb.append((String.format(sectionNameFormatter, accessSection
- .getName().toString())));
+ sb.append((String.format(sectionNameFormatter, accessSection.getName().toString())));
// This is a solution to prevent displaying a section heading unless
// the user has permissions for it
// not the best solution, but I haven't been able to find
@@ -150,11 +153,14 @@
if (groupHash.contains(rule.getGroup().getName())) {
sb.append(String.format(ruleNameFormatter, permission.getName()));
- sb.append(String.format(permissionNameFormatter,
- (!rule.getMin().equals(rule.getMax())) ? "" + rule.getMin() + " "
- + rule.getMax() : rule.getAction(),
- (permission.getExclusiveGroup() ? "EXCLUSIVE" : ""),
- format(rule.getGroup().getName())));
+ sb.append(
+ String.format(
+ permissionNameFormatter,
+ (!rule.getMin().equals(rule.getMax()))
+ ? "" + rule.getMin() + " " + rule.getMax()
+ : rule.getAction(),
+ (permission.getExclusiveGroup() ? "EXCLUSIVE" : ""),
+ format(rule.getGroup().getName())));
userHasPermissionsInSection = true;
}
}
@@ -167,7 +173,6 @@
}
}
-
if (!userHasPermissionsInProject) {
stdout.println(" No access found for this user on this repository");
}