FELIX-3833 Provide flat map of labels to titles for backwards compatibility
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1426552 13f79535-47bb-0310-9956-ffa450edef68
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 8864665..51db475 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
@@ -484,12 +484,12 @@
AbstractWebConsolePlugin plugin = getConsolePlugin(label);
if (plugin != null)
{
- final Map labelMap = holder.getLocalizedLabelMap(resourceBundleManager,
- locale);
+ final Map labelMap = holder.getLocalizedLabelMap( resourceBundleManager, locale );
+ final Object flatLabelMap = labelMap.remove( WebConsoleConstants.ATTR_LABEL_MAP );
// the official request attributes
request.setAttribute(WebConsoleConstants.ATTR_LANG_MAP, getLangMap());
- request.setAttribute(WebConsoleConstants.ATTR_LABEL_MAP, labelMap);
+ request.setAttribute(WebConsoleConstants.ATTR_LABEL_MAP, flatLabelMap);
request.setAttribute(WebConsoleConstants.ATTR_APP_ROOT,
request.getContextPath() + request.getServletPath());
request.setAttribute(WebConsoleConstants.ATTR_PLUGIN_ROOT,
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java
index 494ceb6..1818d3b 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/servlet/PluginHolder.java
@@ -19,7 +19,6 @@
package org.apache.felix.webconsole.internal.servlet;
-import java.util.Comparator;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;
@@ -226,6 +225,10 @@
* resource bundle if the first character of the title is a percent
* sign (%). Titles not prefixed with a percent sign are added to the
* map unmodified.
+ * <p>
+ * The special entry {@code felix.webconsole.labelMap} is the flat,
+ * unstructured map of labels to titles which is used as the
+ * respective request attribute (see FELIX-3833).
*
* @param resourceBundleManager The ResourceBundleManager providing
* localized titles
@@ -236,6 +239,7 @@
Map getLocalizedLabelMap( final ResourceBundleManager resourceBundleManager, final Locale locale )
{
final Map map = new HashMap();
+ final Map flatMap = new HashMap();
Plugin[] plugins = getPlugins();
for ( int i = 0; i < plugins.length; i++ )
{
@@ -274,9 +278,14 @@
/* ignore missing resource - use default title */
}
}
+
categoryMap.put( label, title );
+ flatMap.put( label, title );
}
+ // flat map of labels to titles (FELIX-3833)
+ map.put( WebConsoleConstants.ATTR_LABEL_MAP, flatMap );
+
return map;
}