FELIX-1281 Adding official constants for the request attributes
providing the web console root path and the labe/title map of
plugins.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@789243 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleConstants.java b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleConstants.java
index 2150f93..b917c44 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleConstants.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/WebConsoleConstants.java
@@ -50,4 +50,30 @@
      */
     public static final String PLUGIN_TITLE = "felix.webconsole.title";
 
+    /**
+     * The name of the request attribute providing the absolute path of the
+     * Web Console root (value is "felix.webconsole.appRoot"). This consists of
+     * the servlet context path (from <code>ServletRequest.getContextPath()</code>)
+     * and the configured path of the web console root (<code>/system/console</code>
+     * by default).
+     * <p>
+     * The type of this request attribute is <code>String</code>.
+     *
+     * @since 1.2.12
+     */
+    public static final String ATTR_APP_ROOT = "felix.webconsole.appRoot";
+
+    /**
+     * The name of the request attribute providing a mapping of labels to page
+     * titles of registered console plugins (value is "felix.webconsole.labelMap").
+     * This map may be used to render a navigation of the console plugins as the
+     * {@link AbstractWebConsolePlugin#renderTopNavigation(javax.servlet.http.HttpServletRequest, java.io.PrintWriter)}
+     * method does.
+     * <p>
+     * The type of this request attribute is <code>Map<String, String></code>.
+     *
+     * @since 1.2.12
+     */
+    public static final String ATTR_LABEL_MAP = "felix.webconsole.labelMap";
+
 }
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ComponentsServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ComponentsServlet.java
index ec65265..64c6867 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ComponentsServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ComponentsServlet.java
@@ -33,9 +33,9 @@
 import org.apache.felix.scr.Component;
 import org.apache.felix.scr.Reference;
 import org.apache.felix.scr.ScrService;
+import org.apache.felix.webconsole.WebConsoleConstants;
 import org.apache.felix.webconsole.internal.BaseWebConsolePlugin;
 import org.apache.felix.webconsole.internal.Util;
-import org.apache.felix.webconsole.internal.servlet.OsgiManager;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONWriter;
@@ -141,7 +141,7 @@
         final RequestInfo reqInfo = getRequestInfo(request);
         final PrintWriter pw = response.getWriter();
 
-        final String appRoot = ( String ) request.getAttribute( OsgiManager.ATTR_APP_ROOT );
+        final String appRoot = ( String ) request.getAttribute( WebConsoleConstants.ATTR_APP_ROOT );
 
         Util.startScript( pw );
         pw.println( "var imgRoot = '" + appRoot + "/res/imgs';");
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
index f519ceb..1ad0539 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
@@ -42,8 +42,8 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.felix.webconsole.WebConsoleConstants;
 import org.apache.felix.webconsole.internal.Util;
-import org.apache.felix.webconsole.internal.servlet.OsgiManager;
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONWriter;
@@ -276,7 +276,7 @@
 
         final PrintWriter pw = response.getWriter();
 
-        final String appRoot = (String) request.getAttribute( OsgiManager.ATTR_APP_ROOT );
+        final String appRoot = (String) request.getAttribute( WebConsoleConstants.ATTR_APP_ROOT );
         pw.println( "<script src='" + appRoot + "/res/ui/configmanager.js' language='JavaScript'></script>" );
 
         pw.println( "<table class='content' cellpadding='0' cellspacing='0' width='100%'>" );
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/LogServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/LogServlet.java
index 7400801..b5afd09 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/LogServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/LogServlet.java
@@ -25,9 +25,9 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.felix.webconsole.WebConsoleConstants;
 import org.apache.felix.webconsole.internal.BaseWebConsolePlugin;
 import org.apache.felix.webconsole.internal.Util;
-import org.apache.felix.webconsole.internal.servlet.OsgiManager;
 import org.json.JSONException;
 import org.json.JSONWriter;
 import org.osgi.framework.ServiceReference;
@@ -162,7 +162,7 @@
     {
         final PrintWriter pw = response.getWriter();
 
-        final String appRoot = ( String ) request.getAttribute( OsgiManager.ATTR_APP_ROOT );
+        final String appRoot = ( String ) request.getAttribute( WebConsoleConstants.ATTR_APP_ROOT );
         Util.script( pw, appRoot, "logs.js" );
 
         pw.println( "<div id='plugin_content'/>" );
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
index 1bbcaab..5a709d2 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/core/BundlesServlet.java
@@ -26,9 +26,9 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.felix.bundlerepository.*;
+import org.apache.felix.webconsole.WebConsoleConstants;
 import org.apache.felix.webconsole.internal.BaseWebConsolePlugin;
 import org.apache.felix.webconsole.internal.Util;
-import org.apache.felix.webconsole.internal.servlet.OsgiManager;
 import org.json.*;
 import org.osgi.framework.*;
 import org.osgi.service.cm.ConfigurationAdmin;
@@ -281,7 +281,7 @@
         final RequestInfo reqInfo = getRequestInfo(request);
         final PrintWriter pw = response.getWriter();
 
-        final String appRoot = ( String ) request.getAttribute( OsgiManager.ATTR_APP_ROOT );
+        final String appRoot = ( String ) request.getAttribute( WebConsoleConstants.ATTR_APP_ROOT );
 
         Util.startScript( pw );
         pw.println( "var imgRoot = '" + appRoot + "/res/imgs';");
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/deppack/DepPackServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/deppack/DepPackServlet.java
index a0bee78..599f301 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/deppack/DepPackServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/deppack/DepPackServlet.java
@@ -27,9 +27,9 @@
 
 import org.apache.commons.fileupload.FileItem;
 import org.apache.felix.webconsole.AbstractWebConsolePlugin;
+import org.apache.felix.webconsole.WebConsoleConstants;
 import org.apache.felix.webconsole.internal.BaseWebConsolePlugin;
 import org.apache.felix.webconsole.internal.Util;
-import org.apache.felix.webconsole.internal.servlet.OsgiManager;
 import org.json.JSONException;
 import org.json.JSONWriter;
 import org.osgi.service.component.ComponentContext;
@@ -162,7 +162,7 @@
 
         PrintWriter pw = response.getWriter();
 
-        String appRoot = ( String ) request.getAttribute( OsgiManager.ATTR_APP_ROOT );
+        String appRoot = ( String ) request.getAttribute( WebConsoleConstants.ATTR_APP_ROOT );
         pw.println( "<script src='" + appRoot + "/res/ui/packages.js' language='JavaScript'></script>" );
 
         pw.println( "<h1>Deployment Admin</h1>" );
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/EventAdminServlet.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/EventAdminServlet.java
index 00f8789..129cc5e 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/EventAdminServlet.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/misc/EventAdminServlet.java
@@ -25,9 +25,9 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.felix.webconsole.WebConsoleConstants;
 import org.apache.felix.webconsole.internal.BaseWebConsolePlugin;
 import org.apache.felix.webconsole.internal.Util;
-import org.apache.felix.webconsole.internal.servlet.OsgiManager;
 import org.json.JSONException;
 import org.json.JSONWriter;
 import org.osgi.framework.*;
@@ -233,7 +233,7 @@
     {
         final PrintWriter pw = response.getWriter();
 
-        final String appRoot = ( String ) request.getAttribute( OsgiManager.ATTR_APP_ROOT );
+        final String appRoot = ( String ) request.getAttribute( WebConsoleConstants.ATTR_APP_ROOT );
         Util.script(pw, appRoot, "events.js");
 
         pw.println( "<div id='plugin_content'/>");
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 d167847..b0cfab6 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
@@ -305,8 +305,8 @@
         if ( plugin != null )
         {
             // the official request attributes
-//            req.setAttribute( WebConsoleConstants.ATTR_LABEL_MAP, labelMap );
-//            req.setAttribute( WebConsoleConstants.ATTR_APP_ROOT, request.getContextPath() + request.getServletPath() );
+            req.setAttribute( WebConsoleConstants.ATTR_LABEL_MAP, labelMap );
+            req.setAttribute( WebConsoleConstants.ATTR_APP_ROOT, request.getContextPath() + request.getServletPath() );
 
             // deprecated request attributes
             req.setAttribute( ATTR_LABEL_MAP_OLD, labelMap );