karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggrzy...@apache.org
Subject [karaf] 02/02: [KARAF-5376] Include new Features JAXB model info in feature:* commands
Date Mon, 06 Nov 2017 12:24:33 GMT
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 6c803769546a705e970f6edd880dac348f4f38db
Author: Grzegorz Grzybek <gr.grzybek@gmail.com>
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<Repository> 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" <commits@karaf.apache.org>.

Mime
View raw message