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();
}
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");
}
}
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;
}
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;
}
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;
}
Aggregations