use of org.apache.karaf.shell.support.table.Col in project karaf by apache.
the class Exports method checkDuplicateExports.
private void checkDuplicateExports() {
Bundle[] bundles = bundleContext.getBundles();
SortedMap<String, PackageVersion> packageVersionMap = getDuplicatePackages(bundles);
ShellTable table = new ShellTable();
table.column(new Col("Package Name"));
table.column(new Col("Version"));
table.column(new Col("Exporting bundles (ID)"));
for (String key : packageVersionMap.keySet()) {
PackageVersion pVer = packageVersionMap.get(key);
if (pVer.getBundles().size() > 1) {
String pBundles = getBundlesSt(pVer.getBundles());
table.addRow().addContent(pVer.getPackageName(), pVer.getVersion().toString(), pBundles);
}
}
table.print(System.out, !noFormat);
}
use of org.apache.karaf.shell.support.table.Col in project karaf by apache.
the class ServletListCommand method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column(new Col("ID"));
table.column(new Col("Servlet"));
table.column(new Col("Servlet-Name"));
table.column(new Col("State"));
table.column(new Col("Alias"));
table.column(new Col("Url"));
for (ServletInfo info : servletService.getServlets()) {
table.addRow().addContent(info.getBundleId(), info.getClassName(), info.getName(), info.getStateString(), info.getAlias(), Arrays.toString(info.getUrls()));
}
table.print(System.out, !noFormat);
return null;
}
use of org.apache.karaf.shell.support.table.Col in project fuse-karaf by jboss-fuse.
the class CreateCredentialStore method execute.
/**
* Performs the creation of Credential store according to the given command line options.
*/
@Override
public Object execute() throws Exception {
final Map<String, String> attributes = attributesFromOptions(storeAttributes);
final Provider providerToUse = ProviderHelper.provider(provider);
final Map<String, String> credentialSourceConfiguration = createCredentialSourceConfiguration(credentialType, credentialAttributes);
final CredentialSource credential = credentialType.createCredentialSource(credentialSourceConfiguration);
createCredentialStore(storeAlgorithm, attributes, credential, providerToUse);
final ShellTable table = new ShellTable();
table.column(new Col("Variable"));
table.column(new Col("Value"));
final StringBuilder buffy = new StringBuilder();
if (credentialType != Defaults.CREDENTIAL_TYPE) {
appendConfigurationTo(Collections.singletonMap("CREDENTIAL_STORE_PROTECTION_TYPE", credentialType.name()), table, buffy);
}
appendConfigurationTo(credentialSourceConfiguration, table, buffy);
appendConfigurationTo(attributes.entrySet().stream().collect(Collectors.toMap(e -> "CREDENTIAL_STORE_ATTR_" + e.getKey(), Entry::getValue)), table, buffy);
System.out.println("In order to use this credential store set the following environment variables");
table.print(System.out);
System.out.println("Or simply use this:");
System.out.print(buffy.toString());
return null;
}
use of org.apache.karaf.shell.support.table.Col in project karaf by apache.
the class CommandListHelpProvider method printMethodList.
protected void printMethodList(Session session, PrintStream out, SortedMap<String, String> commands, Collection<String> modes) {
boolean list = false;
boolean cyan = false;
int indent = 0;
for (String mode : modes) {
if (mode.equals("list")) {
list = true;
} else if (mode.equals("cyan")) {
cyan = true;
} else if (mode.equals("indent")) {
indent = 3;
} else if (mode.startsWith("indent=")) {
indent = Integer.parseInt(mode.substring("indent=".length())) - 1;
}
}
Terminal term = session.getTerminal();
int termWidth = term != null ? term.getWidth() : 80;
ShellTable table = new ShellTable().noHeaders().separator(" ").size(termWidth - 1);
Col col = new Col("Command").maxSize(64);
if (indent > 0 || list) {
table.column(new Col(""));
}
if (cyan) {
col.cyan();
} else {
col.bold();
}
table.column(col);
table.column(new Col("Description").wrap());
for (Map.Entry<String, String> entry : commands.entrySet()) {
String key = NameScoping.getCommandNameWithoutGlobalPrefix(session, entry.getKey());
String prefix = "";
for (int i = 0; i < indent; i++) {
prefix += " ";
}
if (list) {
prefix += " *";
}
if (indent > 0 || list) {
table.addRow().addContent(prefix, key, entry.getValue());
} else {
table.addRow().addContent(key, entry.getValue());
}
}
table.print(out, true);
}
use of org.apache.karaf.shell.support.table.Col in project karaf by apache.
the class List method execute.
@Override
public Object execute() throws Exception {
ShellTable table = new ShellTable();
table.column(new Col("ID"));
table.column(new Col("State"));
table.column(new Col("Web-State"));
table.column(new Col("Level"));
table.column(new Col("Web-ContextPath"));
table.column(new Col("Name"));
java.util.List<WebBundle> webBundles = webContainerService.list();
if (webBundles != null && !webBundles.isEmpty()) {
for (WebBundle webBundle : webBundles) {
table.addRow().addContent(webBundle.getBundleId(), webBundle.getState(), webBundle.getWebState(), webBundle.getLevel(), webBundle.getContextPath(), webBundle.getName());
}
}
table.print(System.out, !noFormat);
return null;
}
Aggregations