Search in sources :

Example 31 with ShellTable

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;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) Booking(org.apache.karaf.examples.redis.api.Booking)

Example 32 with ShellTable

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;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) AccessControlContext(java.security.AccessControlContext) Row(org.apache.karaf.shell.support.table.Row) Subject(javax.security.auth.Subject) Principal(java.security.Principal)

Example 33 with ShellTable

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;
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) List(java.util.List) Row(org.apache.karaf.shell.support.table.Row)

Example 34 with ShellTable

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();
}
Also used : Proxy(org.apache.maven.settings.Proxy) ShellTable(org.apache.karaf.shell.support.table.ShellTable) Row(org.apache.karaf.shell.support.table.Row)

Example 35 with ShellTable

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

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