FELIX-3798 Make name of the default category configurable. The default value is "Main"
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1426568 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationMetatypeSupport.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationMetatypeSupport.java
index 0d42b0d..4d0271b 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationMetatypeSupport.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationMetatypeSupport.java
@@ -41,6 +41,7 @@
OsgiManager.PROP_REALM, OsgiManager.DEFAULT_REALM, //
OsgiManager.PROP_USER_NAME, OsgiManager.DEFAULT_USER_NAME, //
OsgiManager.PROP_PASSWORD, OsgiManager.DEFAULT_PASSWORD, //
+ OsgiManager.PROP_CATEGORY, OsgiManager.DEFAULT_CATEGORY, //
OsgiManager.PROP_LOCALE, "", //$NON-NLS-1$
};
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java
index 7a1b086..52f2b34 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/ConfigurationUtil.java
@@ -94,9 +94,10 @@
public static final String getProperty(Map config, String name, String def)
{
Object value = config.get(name);
- if (value instanceof String)
+ if ( value instanceof String )
{
- return (String) value;
+ final String s = ( ( String ) value ).trim();
+ return ( s.length() > 0 ) ? s : def;
}
if (value == null)
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
index aff9c9c..7d05d7b 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/OsgiManager.java
@@ -141,6 +141,8 @@
static final String PROP_PASSWORD = "password"; //$NON-NLS-1$
+ static final String PROP_CATEGORY = "category"; //$NON-NLS-1$
+
static final String PROP_ENABLED_PLUGINS = "plugins"; //$NON-NLS-1$
static final String PROP_LOG_LEVEL = "loglevel"; //$NON-NLS-1$
@@ -159,6 +161,8 @@
static final String DEFAULT_PASSWORD = "admin"; //$NON-NLS-1$
+ static final String DEFAULT_CATEGORY = "Main"; //$NON-NLS-1$
+
static final String DEFAULT_HTTP_SERVICE_SELECTOR = ""; //$NON-NLS-1$
/**
@@ -227,6 +231,8 @@
private int logLevel = DEFAULT_LOG_LEVEL;
+ private String defaultCategory = DEFAULT_CATEGORY;
+
public OsgiManager(BundleContext bundleContext)
{
this.bundleContext = bundleContext;
@@ -490,7 +496,7 @@
AbstractWebConsolePlugin plugin = getConsolePlugin(label);
if (plugin != null)
{
- final Map labelMap = holder.getLocalizedLabelMap( resourceBundleManager, locale, "Main" );
+ final Map labelMap = holder.getLocalizedLabelMap( resourceBundleManager, locale, this.defaultCategory );
final Object flatLabelMap = labelMap.remove( WebConsoleConstants.ATTR_LABEL_MAP );
// the official request attributes
@@ -940,6 +946,9 @@
newWebManagerRoot = "/" + newWebManagerRoot; //$NON-NLS-1$
}
+ // default category
+ this.defaultCategory = ConfigurationUtil.getProperty( config, PROP_CATEGORY, DEFAULT_CATEGORY );
+
// get the HTTP Service selector (and dispose tracker for later
// recreation)
final String newHttpServiceSelector = ConfigurationUtil.getProperty(config,
diff --git a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
index f6b8218..3ad3e4a 100644
--- a/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
+++ b/webconsole/src/main/resources/OSGI-INF/l10n/bundle.properties
@@ -236,6 +236,12 @@
OSGi Management Console. This property is ignored if a \
WebConsoleSecurityProvider is used for authentication.
+metadata.category.name=Default Category
+metadata.category.description=The default category (menu label) to be used \
+ for plugins not registered with a felix.webconsole.category service \
+ property or overwriting the AbstractWebConsole.getCategory() method. The \
+ default value is "Main".
+
metadata.plugins.name=Plugins
metadata.plugins.description=Select active plugins
diff --git a/webconsole/src/main/resources/OSGI-INF/l10n/bundle_de.properties b/webconsole/src/main/resources/OSGI-INF/l10n/bundle_de.properties
index 8250b56..a3e84cc 100644
--- a/webconsole/src/main/resources/OSGI-INF/l10n/bundle_de.properties
+++ b/webconsole/src/main/resources/OSGI-INF/l10n/bundle_de.properties
@@ -234,6 +234,12 @@
verwendet falls ein WebConsoleSecurityProvider service für die Authentisierung \
verwendet wird.
+metadata.category.name=Standard Kategorie
+metadata.category.description=Die Standard Kategorie (Menu) for plugins, \
+ die nicht mit der felix.webconsole.category service property registriert \
+ sind oder die AbstractWebConsole.getCategory() Methode überschreiben. Der \
+ Standardwert ist "Main".
+
metadata.plugins.name=Plugins
metadata.plugins.description=Aktive Plugins auswählen