Search in sources :

Example 36 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class Exports method showExports.

private void showExports() {
    List<PackageVersion> exports = packageService.getExports();
    ShellTable table = new ShellTable();
    table.column("Package Name");
    if (!showOnlyName) {
        table.column("Version");
        table.column("ID");
        table.column("Bundle Name");
    }
    for (PackageVersion pVer : exports) {
        for (Bundle bundle : pVer.getBundles()) {
            if (matchesFilter(pVer, bundle)) {
                if (!showOnlyName) {
                    table.addRow().addContent(pVer.getPackageName(), pVer.getVersion().toString(), bundle.getBundleId(), bundle.getSymbolicName());
                } else {
                    table.addRow().addContent(pVer.getPackageName());
                }
            }
        }
    }
    table.print(System.out, !noFormat);
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) Bundle(org.osgi.framework.Bundle) PackageVersion(org.apache.karaf.packages.core.PackageVersion)

Example 37 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class ListUrlCommand method doExecute.

protected void doExecute(RepositoryAdmin admin) {
    ShellTable table = new ShellTable();
    table.column("Index");
    table.column("OBR URL");
    table.emptyTableText("No OBR repository URL");
    Repository[] repos = admin.listRepositories();
    if (repos != null) {
        for (int i = 0; i < repos.length; i++) {
            table.addRow().addContent(i, repos[i].getURI());
        }
    }
    table.print(System.out, !noFormat);
}
Also used : Repository(org.apache.felix.bundlerepository.Repository) ShellTable(org.apache.karaf.shell.support.table.ShellTable)

Example 38 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable 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)

Example 39 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class List method doExecute.

@Override
protected Object doExecute(java.util.List<Bundle> bundles) throws Exception {
    if (noFormat) {
        noEllipsis = true;
    }
    determineBundleLevelThreshold();
    // Display active start level.
    FrameworkStartLevel fsl = this.bundleContext.getBundle(0).adapt(FrameworkStartLevel.class);
    if (fsl != null) {
        System.out.println("START LEVEL " + fsl.getStartLevel() + " , List Threshold: " + bundleLevelThreshold);
    }
    ShellTable table = new ShellTable();
    if (!noEllipsis && terminal != null && terminal.getWidth() > 0) {
        table.size(terminal.getWidth() - 1);
    }
    table.column("ID").alignRight();
    table.column("State");
    table.column("Lvl").alignRight();
    table.column("Version");
    boolean effectiveShowName = showName || (!showLocation && !showSymbolic && !showUpdate && !showRevisions);
    if (effectiveShowName) {
        table.column("Name");
    }
    if (showLocation) {
        table.column(new Col("Location") {

            @Override
            protected String cut(String value, int size) {
                if (showLocation && value.length() > size) {
                    String[] parts = value.split("/");
                    String cut = "";
                    int c = parts[0].length() + 4;
                    for (int idx = parts.length - 1; idx > 0; idx--) {
                        if (cut.length() + c + parts[idx].length() + 1 < size) {
                            cut = "/" + parts[idx] + cut;
                        } else {
                            break;
                        }
                    }
                    cut = parts[0] + "/..." + cut;
                    return cut;
                } else {
                    return super.cut(value, size);
                }
            }
        });
    }
    if (showSymbolic) {
        table.column("Symbolic name");
    }
    if (showUpdate) {
        table.column("Update location");
    }
    if (showRevisions) {
        table.column("Revisions");
    }
    for (Bundle bundle : bundles) {
        BundleInfo info = this.bundleService.getInfo(bundle);
        if (info.getStartLevel() >= bundleLevelThreshold) {
            String version = info.getVersion();
            ArrayList<Object> rowData = new ArrayList<>();
            rowData.add(info.getBundleId());
            rowData.add(getStateString(info.getState()));
            rowData.add(info.getStartLevel());
            rowData.add(version);
            if (effectiveShowName) {
                String bundleName = (info.getName() == null) ? info.getSymbolicName() : info.getName();
                bundleName = (bundleName == null) ? info.getUpdateLocation() : bundleName;
                String name = bundleName + printFragments(info) + printHosts(info);
                rowData.add(name);
            }
            if (showLocation) {
                rowData.add(info.getUpdateLocation());
            }
            if (showSymbolic) {
                rowData.add(info.getSymbolicName() == null ? "<no symbolic name>" : info.getSymbolicName());
            }
            if (showUpdate) {
                rowData.add(info.getUpdateLocation());
            }
            if (showRevisions) {
                rowData.add(info.getRevisions());
            }
            Row row = table.addRow();
            row.addContent(rowData);
        }
    }
    table.print(System.out, !noFormat);
    return null;
}
Also used : Col(org.apache.karaf.shell.support.table.Col) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) FrameworkStartLevel(org.osgi.framework.startlevel.FrameworkStartLevel) ShellTable(org.apache.karaf.shell.support.table.ShellTable) BundleInfo(org.apache.karaf.bundle.core.BundleInfo) Row(org.apache.karaf.shell.support.table.Row)

Example 40 with ShellTable

use of org.apache.karaf.shell.support.table.ShellTable in project karaf by apache.

the class ImagesCommand method execute.

@Override
public Object execute() throws Exception {
    ShellTable table = new ShellTable();
    table.column("Id");
    table.column("RepoTags");
    table.column("Created");
    table.column("Labels");
    table.column("Size");
    table.column("Virtual Size");
    for (Image image : getDockerService().images(url)) {
        table.addRow().addContent(image.getId(), image.getRepoTags(), image.getCreated(), image.getLabels(), image.getSize(), image.getVirtualSize());
    }
    table.print(System.out);
    return null;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) Image(org.apache.karaf.docker.Image)

Aggregations

ShellTable (org.apache.karaf.shell.support.table.ShellTable)59 Row (org.apache.karaf.shell.support.table.Row)10 Col (org.apache.karaf.shell.support.table.Col)7 ArrayList (java.util.ArrayList)4 Bundle (org.osgi.framework.Bundle)4 Map (java.util.Map)3 Feature (org.apache.karaf.features.Feature)3 Repository (org.apache.karaf.features.Repository)3 List (java.util.List)2 TreeMap (java.util.TreeMap)2 Bus (org.apache.cxf.Bus)2 Booking (org.apache.karaf.examples.jdbc.api.Booking)2 Booking (org.apache.karaf.examples.jpa.Booking)2 MavenRepositoryURL (org.apache.karaf.maven.core.MavenRepositoryURL)2 Attribute (ddf.catalog.data.Attribute)1 Result (ddf.catalog.data.Result)1 SortByImpl (ddf.catalog.filter.impl.SortByImpl)1 QueryRequest (ddf.catalog.operation.QueryRequest)1 SourceResponse (ddf.catalog.operation.SourceResponse)1 QueryImpl (ddf.catalog.operation.impl.QueryImpl)1