Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id B3D26200D3A for ; Wed, 15 Nov 2017 16:29:27 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id B1F80160C09; Wed, 15 Nov 2017 15:29:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D9C01160BEA for ; Wed, 15 Nov 2017 16:29:26 +0100 (CET) Received: (qmail 59558 invoked by uid 500); 15 Nov 2017 15:29:26 -0000 Mailing-List: contact commits-help@karaf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@karaf.apache.org Delivered-To: mailing list commits@karaf.apache.org Received: (qmail 59549 invoked by uid 99); 15 Nov 2017 15:29:26 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Nov 2017 15:29:26 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 7D39981B4B; Wed, 15 Nov 2017 15:29:25 +0000 (UTC) Date: Wed, 15 Nov 2017 15:29:27 +0000 To: "commits@karaf.apache.org" Subject: [karaf] 02/07: [KARAF-5376] Include new Features JAXB model info in feature:* commands MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit From: ggrzybek@apache.org In-Reply-To: <151075976534.12634.15161700733085528883@gitbox.apache.org> References: <151075976534.12634.15161700733085528883@gitbox.apache.org> X-Git-Host: gitbox.apache.org X-Git-Repo: karaf X-Git-Refname: refs/heads/KARAF-5376-overrides_v2 X-Git-Reftype: branch X-Git-Rev: ddeb7db58fe40f2e5ff40cdb78622a59112457b1 X-Git-NotificationType: diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated Message-Id: <20171115152925.7D39981B4B@gitbox.apache.org> archived-at: Wed, 15 Nov 2017 15:29:27 -0000 This is an automated email from the ASF dual-hosted git repository. ggrzybek pushed a commit to branch KARAF-5376-overrides_v2 in repository https://gitbox.apache.org/repos/asf/karaf.git commit ddeb7db58fe40f2e5ff40cdb78622a59112457b1 Author: Grzegorz Grzybek AuthorDate: Mon Nov 6 13:24:22 2017 +0100 [KARAF-5376] Include new Features JAXB model info in feature:* commands --- .../karaf/features/command/InfoFeatureCommand.java | 3 +++ .../features/command/ListFeaturesCommand.java | 17 +++++++++++++++- .../karaf/features/command/RepoListCommand.java | 23 +++++++++++++++++----- .../internal/service/RepositoryCacheImpl.java | 2 ++ .../features/internal/service/RepositoryImpl.java | 6 ++++++ 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/features/command/src/main/java/org/apache/karaf/features/command/InfoFeatureCommand.java b/features/command/src/main/java/org/apache/karaf/features/command/InfoFeatureCommand.java index 1ecc0a0..7c6a775 100644 --- a/features/command/src/main/java/org/apache/karaf/features/command/InfoFeatureCommand.java +++ b/features/command/src/main/java/org/apache/karaf/features/command/InfoFeatureCommand.java @@ -209,6 +209,9 @@ public class InfoFeatureCommand extends FeaturesCommandSupport { if(startLevel > 0) { sb.append(" start-level=").append(startLevel); } + if (featureBundle.isOverriden()) { + sb.append(" (overriden from " + featureBundle.getOriginalLocation() + ")"); + } System.out.println(sb.toString()); } } diff --git a/features/command/src/main/java/org/apache/karaf/features/command/ListFeaturesCommand.java b/features/command/src/main/java/org/apache/karaf/features/command/ListFeaturesCommand.java index 6bf9f9c..9e17153 100644 --- a/features/command/src/main/java/org/apache/karaf/features/command/ListFeaturesCommand.java +++ b/features/command/src/main/java/org/apache/karaf/features/command/ListFeaturesCommand.java @@ -27,6 +27,7 @@ import org.apache.karaf.features.Repository; import org.apache.karaf.shell.api.action.Command; import org.apache.karaf.shell.api.action.Option; import org.apache.karaf.shell.api.action.lifecycle.Service; +import org.apache.karaf.shell.support.table.Row; import org.apache.karaf.shell.support.table.ShellTable; @Command(scope = "feature", name = "list", description = "Lists all existing features available from the defined repositories.") @@ -42,6 +43,9 @@ public class ListFeaturesCommand extends FeaturesCommandSupport { @Option(name = "-s", aliases = {"--show-hidden"}, description = "Display hidden features", required = false, multiValued = false) boolean showHidden; + @Option(name = "-b", aliases = {"--show-blacklisted"}, description = "Display blacklisted features", required = false, multiValued = false) + boolean showBlacklisted; + @Option(name = "-o", aliases = {"--ordered"}, description = "Display a list using alphabetical order ", required = false, multiValued = false) boolean ordered; @@ -58,6 +62,9 @@ public class ListFeaturesCommand extends FeaturesCommandSupport { 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 repos = Arrays.asList(featuresService.listRepositories()); @@ -75,17 +82,25 @@ public class ListFeaturesCommand extends FeaturesCommandSupport { // 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; } - table.addRow().addContent( + 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; } diff --git a/features/command/src/main/java/org/apache/karaf/features/command/RepoListCommand.java b/features/command/src/main/java/org/apache/karaf/features/command/RepoListCommand.java index 50f3b95..a91182f 100644 --- a/features/command/src/main/java/org/apache/karaf/features/command/RepoListCommand.java +++ b/features/command/src/main/java/org/apache/karaf/features/command/RepoListCommand.java @@ -25,6 +25,7 @@ import org.apache.karaf.shell.api.action.Command; import org.apache.karaf.shell.api.action.Option; import org.apache.karaf.shell.api.action.lifecycle.Service; import org.apache.karaf.shell.support.MultiException; +import org.apache.karaf.shell.support.table.Row; import org.apache.karaf.shell.support.table.ShellTable; @Command(scope = "feature", name = "repo-list", description = "Displays a list of all defined repositories.") @@ -34,9 +35,12 @@ public class RepoListCommand extends FeaturesCommandSupport { @Option(name="-r", description="Reload all feature urls", required = false, multiValued = false) boolean reload; + @Option(name = "-b", aliases = { " --show-blacklisted" }, description = "Also display blacklisted repositories", required = false, multiValued = false) + boolean showBlacklisted = false; + @Option(name = "--no-format", description = "Disable table rendered output", required = false, multiValued = false) boolean noFormat; - + protected void doExecute(FeaturesService featuresService) throws Exception { if (reload) { reloadAllRepos(featuresService); @@ -45,15 +49,24 @@ public class RepoListCommand extends FeaturesCommandSupport { ShellTable table = new ShellTable(); table.column("Repository"); table.column("URL"); + if (showBlacklisted) { + table.column("Blacklisted"); + } table.emptyTableText("No repositories available"); Repository[] repos = featuresService.listRepositories(); - for (Repository repo : repos) { + for (Repository repo : repos) { if (repo != null) { - table.addRow().addContent(repo.getName(), repo.getURI().toString()); + if (showBlacklisted || !repo.isBlacklisted()) { + Row row = table.addRow(); + row.addContent(repo.getName(), repo.getURI().toString()); + if (showBlacklisted) { + row.addContent(repo.isBlacklisted() ? "yes" : "no"); + } + } } - } - table.print(System.out, !noFormat); + } + table.print(System.out, !noFormat); } private void reloadAllRepos(FeaturesService featuresService) throws Exception { diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryCacheImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryCacheImpl.java index d33b39d..9874a20 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryCacheImpl.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryCacheImpl.java @@ -46,7 +46,9 @@ public class RepositoryCacheImpl implements RepositoryCache { public Repository create(URI uri, boolean validate) { RepositoryImpl repository = new RepositoryImpl(uri, validate); if (featuresProcessor != null) { + // maybe it could be done better - first we have to set if entire repo is blacklisted repository.setBlacklisted(featuresProcessor.isRepositoryBlacklisted(uri)); + // processing features will take the above flag into account to blacklist (if needed) the features repository.processFeatures(featuresProcessor); } return repository; diff --git a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java b/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java index 31aadaf..3d76c23 100644 --- a/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java +++ b/features/core/src/main/java/org/apache/karaf/features/internal/service/RepositoryImpl.java @@ -107,6 +107,12 @@ public class RepositoryImpl implements Repository { */ public void processFeatures(FeaturesProcessor processor) { processor.process(features); + if (blacklisted) { + // all features of blacklisted repository are blacklisted too + for (org.apache.karaf.features.internal.model.Feature feature : features.getFeature()) { + feature.setBlacklisted(true); + } + } } static class InterruptibleInputStream extends FilterInputStream { -- To stop receiving notification emails like this one, please contact "commits@karaf.apache.org" .