Search in sources :

Example 1 with Col

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);
}
Also used : Col(org.apache.karaf.shell.support.table.Col) ShellTable(org.apache.karaf.shell.support.table.ShellTable) Bundle(org.osgi.framework.Bundle) PackageVersion(org.apache.karaf.packages.core.PackageVersion)

Example 2 with Col

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;
}
Also used : ServletInfo(org.apache.karaf.http.core.ServletInfo) Col(org.apache.karaf.shell.support.table.Col) ShellTable(org.apache.karaf.shell.support.table.ShellTable)

Example 3 with Col

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;
}
Also used : Col(org.apache.karaf.shell.support.table.Col) Entry(java.util.Map.Entry) ShellTable(org.apache.karaf.shell.support.table.ShellTable) Provider(java.security.Provider) CredentialSource(org.wildfly.security.credential.source.CredentialSource)

Example 4 with Col

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);
}
Also used : Col(org.apache.karaf.shell.support.table.Col) ShellTable(org.apache.karaf.shell.support.table.ShellTable) Terminal(org.apache.karaf.shell.api.console.Terminal) TreeMap(java.util.TreeMap) Map(java.util.Map) SortedMap(java.util.SortedMap)

Example 5 with Col

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;
}
Also used : Col(org.apache.karaf.shell.support.table.Col) ShellTable(org.apache.karaf.shell.support.table.ShellTable) WebBundle(org.apache.karaf.web.WebBundle)

Aggregations

Col (org.apache.karaf.shell.support.table.Col)7 ShellTable (org.apache.karaf.shell.support.table.ShellTable)7 Bundle (org.osgi.framework.Bundle)2 Provider (java.security.Provider)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1 BundleInfo (org.apache.karaf.bundle.core.BundleInfo)1 ServletInfo (org.apache.karaf.http.core.ServletInfo)1 PackageVersion (org.apache.karaf.packages.core.PackageVersion)1 Terminal (org.apache.karaf.shell.api.console.Terminal)1 Row (org.apache.karaf.shell.support.table.Row)1 WebBundle (org.apache.karaf.web.WebBundle)1 FrameworkStartLevel (org.osgi.framework.startlevel.FrameworkStartLevel)1 CredentialSource (org.wildfly.security.credential.source.CredentialSource)1 CredentialStore (org.wildfly.security.credential.store.CredentialStore)1