use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class ListBookingCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column("ID");
table.column("Customer");
table.column("Flight");
for (Booking booking : bookingService.list()) {
table.addRow().addContent(booking.getId(), booking.getCustomer(), booking.getFlight());
}
table.print(System.out);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class WhoamiCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
// Get the currently-active JAAS Subject.
AccessControlContext acc = AccessController.getContext();
Subject subj = Subject.getSubject(acc);
String classString = USER_CLASS;
if (groups) {
classString = GROUP_CLASS;
} else if (roles) {
classString = ROLE_CLASS;
} else if (all) {
classString = ALL_CLASS;
}
Class c = Class.forName(classString);
Set<Principal> principals = subj.getPrincipals(c);
table.column("Name");
if (all) {
table.column("Class");
}
for (Principal p : principals) {
Row row = table.addRow();
row.addContent(p.getName());
if (all) {
row.addContent(p.getClass().getCanonicalName());
}
}
table.print(System.out, !noFormat);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class TablesCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
Map<String, List<String>> map = this.getJdbcService().tables(datasource);
int rowCount = 0;
for (String column : map.keySet()) {
table.column(column);
rowCount = map.get(column).size();
}
for (int i = 0; i < rowCount; i++) {
Row row = table.addRow();
for (String column : map.keySet()) {
row.addContent(map.get(column).get(i));
}
}
table.print(System.out);
return null;
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class HttpProxyListCommand method doAction.
@Override
public void doAction(String prefix, Dictionary<String, Object> config) throws Exception {
System.out.println();
if (mavenSettings != null && mavenSettings.getProxies() != null && mavenSettings.getProxies().size() > 0) {
ShellTable table = new ShellTable();
table.column("ID");
table.column("Host");
table.column("Port");
table.column("Non-proxy hosts");
table.column("Username");
if (showPasswords) {
table.column("Password");
}
for (Proxy _p : mavenSettings.getProxies()) {
Row row = table.addRow();
row.addContent(_p.getId(), _p.getHost(), _p.getPort(), _p.getNonProxyHosts());
row.addContent(_p.getUsername() != null ? _p.getUsername() : "");
if (showPasswords) {
addPasswordInfo(row, proxyPasswords, _p.getId(), _p.getPassword());
}
}
table.print(System.out);
} else {
System.out.print("No HTTP proxies configured");
if (settings != null && settings.value != null) {
System.out.print(" in " + settings.value);
}
System.out.println();
}
System.out.println();
}
use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.
the class Imports method execute.
@Override
public Object execute() throws Exception {
List<PackageRequirement> imports = packageService.getImports();
ShellTable table = new ShellTable();
if (showFilter) {
table.column("Filter");
table.column("Optional");
table.column("ID");
table.column("Bundle Name");
} else {
table.column("Package");
if (!showOnlyName) {
table.column("Version");
table.column("Optional");
table.column("ID");
table.column("Bundle Name");
}
}
for (PackageRequirement req : imports) {
if (matchesFilter(req)) {
Bundle bundle = req.getBundle();
Row row = table.addRow();
if (showFilter) {
row.addContent(req.getFilter());
row.addContent(getOptional(req), bundle.getBundleId(), bundle.getSymbolicName());
} else {
row.addContent(req.getPackageName());
if (!showOnlyName) {
row.addContent(req.getVersionRange());
row.addContent(getOptional(req), bundle.getBundleId(), bundle.getSymbolicName());
}
}
}
}
table.print(System.out, !noFormat);
return null;
}
Aggregations