You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2016/07/18 07:20:34 UTC

karaf git commit: [KARAF-4493] Add support of etc/branding-ssh.properties file to brand the ssh terminal

Repository: karaf
Updated Branches:
  refs/heads/karaf-4.0.x fc2dd8417 -> 20a509a9e


[KARAF-4493] Add support of etc/branding-ssh.properties file to brand the ssh terminal


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/20a509a9
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/20a509a9
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/20a509a9

Branch: refs/heads/karaf-4.0.x
Commit: 20a509a9e1ff266459532b36690d464b920cd802
Parents: fc2dd84
Author: mhautman <mo...@gmail.com>
Authored: Fri Jul 8 21:06:28 2016 +0200
Committer: Jean-Baptiste Onofr� <jb...@apache.org>
Committed: Mon Jul 18 09:20:25 2016 +0200

----------------------------------------------------------------------
 .../karaf/shell/impl/console/Branding.java      | 45 ++++++--------------
 1 file changed, 12 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/20a509a9/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java
----------------------------------------------------------------------
diff --git a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java
index ba3d98f..f454e93 100644
--- a/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java
+++ b/shell/core/src/main/java/org/apache/karaf/shell/impl/console/Branding.java
@@ -18,23 +18,17 @@
  */
 package org.apache.karaf.shell.impl.console;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
+import org.apache.karaf.shell.api.console.Terminal;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import org.apache.karaf.shell.api.console.Terminal;
+import java.io.*;
+import java.util.Properties;
 
 
 public final class Branding {
-   
     static final Logger LOGGER = LoggerFactory.getLogger(Branding.class);
-     
+
     private Branding() { }
 
     public static Properties loadBrandingProperties() {
@@ -47,15 +41,16 @@ public final class Branding {
     public static Properties loadBrandingProperties(Terminal terminal) {
         Properties props = new Properties();
         if (terminal != null && terminal.getClass().getName().endsWith("SshTerminal")) {
-            //it's a ssh client, so load branding seperately
             loadProps(props, "org/apache/karaf/shell/console/branding-ssh.properties");
+            return loadEtcBrandingFile("branding-ssh.properties",props);
         } else {
             loadProps(props, "org/apache/karaf/shell/console/branding.properties");
+            return loadEtcBrandingFile("branding.properties",props);
         }
+    }
 
-        loadProps(props, "org/apache/karaf/branding/branding.properties");
-        // load branding from etc/branding.properties
-        File etcBranding = new File(System.getProperty("karaf.etc"), "branding.properties");
+    private static Properties loadEtcBrandingFile(String fileName, Properties props){
+        File etcBranding = new File(System.getProperty("karaf.etc"), fileName);
         if (etcBranding.exists()) {
             FileInputStream etcBrandingIs = null;
             try {
@@ -65,28 +60,12 @@ public final class Branding {
             }
             loadProps(props, etcBrandingIs);
         }
-
         return props;
     }
-    
+
     protected static void loadProps(Properties props, String resource) {
-        InputStream is = null;
-        try {
-            is = Branding.class.getClassLoader().getResourceAsStream(resource);
-            if (is != null) {
-                props.load(is);
-            }
-        } catch (IOException e) {
-            // ignore
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException e) {
-                    // Ignore
-                }
-            }
-        }
+        InputStream is = Branding.class.getClassLoader().getResourceAsStream(resource);
+        loadProps(props, is);
     }
 
     protected static void loadProps(Properties props, InputStream is) {