in src/main/java/com/googlesource/gerrit/plugins/adminconsole/ShowRepoAccessCommand.java [61:100]
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 ";
String permissionNameFormatter = " %5s %9s %s\n";
if (projectName.isEmpty()) {
throw new UnloggedFailure(1, "Please specify a project to show access for");
}
Project.NameKey nameKey = Project.nameKey(projectName);
permissionGroupWidth = wide ? Integer.MAX_VALUE : columns - 9 - 5 - 9;
ProjectConfig config;
try {
MetaDataUpdate md = metaDataUpdateFactory.create(nameKey);
config = projectConfigFactory.read(md);
for (AccessSection accessSection : config.getAccessSections()) {
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() != rule.getMax())
? "" + rule.getMin() + " " + rule.getMax()
: rule.getAction(),
(permission.getExclusiveGroup() ? "EXCLUSIVE" : ""),
format(rule.getGroup().getName())));
}
}
}
} catch (RepositoryNotFoundException e) {
throw new UnloggedFailure(1, "Repository not found");
}
}