Search in sources :

Example 1 with Row

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

the class RepositoryListCommand method doAction.

@Override
public void doAction(String prefix, Dictionary<String, Object> config) throws Exception {
    ShellTable table = new ShellTable();
    table.column("ID");
    table.column("URL");
    if (verbose) {
        table.column("Releases");
        table.column("Snapshots");
        table.column("Defined in");
    }
    if (showPasswords) {
        table.column("Username");
        table.column("Password");
    }
    System.out.println();
    System.out.println("== Remote repositories");
    MavenRepositoryURL[] repositories = repositories(config, true);
    for (MavenRepositoryURL repoURL : repositories) {
        Row row = table.addRow();
        row.addContent(repoURL.getId(), repoURL.getURL());
        if (verbose) {
            row.addContent(repositoryKindInfo(repoURL, false), repositoryKindInfo(repoURL, true), repoURL.getFrom());
        }
        if (showPasswords) {
            if (servers.containsKey(repoURL.getId())) {
                Server server = servers.get(repoURL.getId());
                row.addContent(server.getUsername() == null ? "" : server.getUsername());
                addPasswordInfo(row, serverPasswords, repoURL.getId(), server.getPassword());
            } else {
                row.addContent("", "");
            }
        }
    }
    table.print(System.out);
    table = new ShellTable();
    table.column("ID");
    table.column("URL");
    if (verbose) {
        table.column("Releases");
        table.column("Snapshots");
    }
    System.out.println();
    System.out.println("== Default repositories");
    repositories = repositories(config, false);
    for (MavenRepositoryURL repoURL : repositories) {
        Row row = table.addRow();
        row.addContent(repoURL.getId(), repoURL.getURL());
        if (verbose) {
            row.addContent(repositoryKindInfo(repoURL, false), repositoryKindInfo(repoURL, true), repoURL.getFrom());
        }
    }
    table.print(System.out);
    System.out.println();
}
Also used : ShellTable(org.apache.karaf.shell.support.table.ShellTable) Server(org.apache.maven.settings.Server) MavenRepositoryURL(org.apache.karaf.maven.core.MavenRepositoryURL) Row(org.apache.karaf.shell.support.table.Row)

Example 2 with Row

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

the class ListFeaturesCommand method doExecute.

protected void doExecute(FeaturesService featuresService) throws Exception {
    boolean needsLegend = false;
    ShellTable table = new ShellTable();
    table.column("Name");
    table.column("Version");
    table.column("Required");
    table.column("State");
    table.column("Repository");
    table.column("Description").maxSize(50);
    if (showBlacklisted) {
        table.column("Blacklisted");
    }
    table.emptyTableText(onlyInstalled ? "No features installed" : "No features available");
    List<Repository> repos = Arrays.asList(featuresService.listRepositories());
    for (Repository r : repos) {
        List<Feature> features = Arrays.asList(r.getFeatures());
        if (ordered) {
            Collections.sort(features, new FeatureComparator());
        }
        for (Feature f : features) {
            if (onlyInstalled && !featuresService.isInstalled(f)) {
                // Filter out not installed features if we only want to see the installed ones
                continue;
            }
            if (onlyRequired && !featuresService.isRequired(f)) {
                // Filter out not installed features if we only want to see the installed ones
                continue;
            }
            if (!showBlacklisted && f.isBlacklisted()) {
                // Filter out blacklisted
                continue;
            }
            if (!showHidden && f.isHidden()) {
                // Filter out hidden feature if not asked to display those
                continue;
            }
            Row row = table.addRow();
            row.addContent(f.getName(), f.getVersion(), featuresService.isRequired(f) ? "x" : "", featuresService.getState(f.getId()), r.getName(), f.getDescription());
            if (showBlacklisted) {
                row.addContent(f.isBlacklisted() ? "yes" : "no");
            }
            if (isInstalledViaDeployDir(r.getName())) {
                needsLegend = true;
            }
        }
    }
    table.print(System.out, !noFormat);
    if (needsLegend) {
        System.out.println("* Installed via deploy directory");
    }
}
Also used : Repository(org.apache.karaf.features.Repository) ShellTable(org.apache.karaf.shell.support.table.ShellTable) Row(org.apache.karaf.shell.support.table.Row) Feature(org.apache.karaf.features.Feature)

Example 3 with Row

use of org.apache.karaf.shell.support.table.Row 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 4 with Row

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

Example 5 with Row

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

the class QueryCommand method execute.

@Override
public Object execute() throws Exception {
    ShellTable table = new ShellTable();
    Map<String, List<String>> map = this.getJdbcService().query(datasource, query);
    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)

Aggregations

Row (org.apache.karaf.shell.support.table.Row)11 ShellTable (org.apache.karaf.shell.support.table.ShellTable)10 List (java.util.List)2 Repository (org.apache.karaf.features.Repository)2 Bundle (org.osgi.framework.Bundle)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 QueryRequestImpl (ddf.catalog.operation.impl.QueryRequestImpl)1 AccessControlContext (java.security.AccessControlContext)1 Principal (java.security.Principal)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Subject (javax.security.auth.Subject)1 BundleInfo (org.apache.karaf.bundle.core.BundleInfo)1