You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2017/01/17 16:38:08 UTC

svn commit: r1779210 - in /felix/trunk/webconsole-plugins/ds: ./ src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ src/main/resources/res/

Author: cziegeler
Date: Tue Jan 17 16:38:08 2017
New Revision: 1779210

URL: http://svn.apache.org/viewvc?rev=1779210&view=rev
Log:
FELIX-5496 : Use bundle id and component name as key for urls

Modified:
    felix/trunk/webconsole-plugins/ds/changelog.txt
    felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java
    felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java
    felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.js

Modified: felix/trunk/webconsole-plugins/ds/changelog.txt
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/changelog.txt?rev=1779210&r1=1779209&r2=1779210&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/ds/changelog.txt (original)
+++ felix/trunk/webconsole-plugins/ds/changelog.txt Tue Jan 17 16:38:08 2017
@@ -2,6 +2,7 @@ Changes from 2.0.4 to 2.0.6
 ---------------------------
 ** Improvement
     * [FELIX-5495] : No details displayed if component is disabled
+    * [FELIX-5496] : Use bundle id and component name as key for urls
 ** Bug
     * [FELIX-5493] : Component descriptions requiring a policy are not displayed if config is missing
     * [FELIX-5494] : URL handling not correct if component has no configuration

Modified: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java?rev=1779210&r1=1779209&r2=1779210&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java (original)
+++ felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/ComponentConfigurationPrinter.java Tue Jan 17 16:38:08 2017
@@ -111,12 +111,12 @@ class ComponentConfigurationPrinter impl
         // render disabled descriptions
         for(final ComponentDescriptionDTO cd : disabled)
         {
-            plugin.disabledComponent(jw, cd, details);
+            plugin.component(jw, cd, null, details);
         }
         // render configurations
         for (final ComponentConfigurationDTO cfg : configurations)
         {
-            plugin.component(jw, cfg, details);
+            plugin.component(jw, cfg.description, cfg, details);
         }
 
         jw.endArray();

Modified: felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java?rev=1779210&r1=1779209&r2=1779210&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java (original)
+++ felix/trunk/webconsole-plugins/ds/src/main/java/org/apache/felix/webconsole/plugins/ds/internal/WebConsolePlugin.java Tue Jan 17 16:38:08 2017
@@ -229,22 +229,22 @@ class WebConsolePlugin extends SimpleWeb
                 {
                     if ( component.state == -1 )
                     {
-                        disabledComponent(jw, component.description, true);
+                        component(jw, component.description, null, true);
                     }
                     else
                     {
-                        component(jw, component, true);
+                        component(jw, component.description, component, true);
                     }
                 }
                 else
                 {
                     for( final ComponentDescriptionDTO cd : info.disabled )
                     {
-                        disabledComponent(jw, cd, false);
+                        component(jw, cd, null, false);
                     }
                     for (final ComponentConfigurationDTO cfg : info.configurations)
                     {
-                        component(jw, cfg, false);
+                        component(jw, cfg.description, cfg, false);
                     }
                 }
                 jw.endArray();
@@ -274,62 +274,49 @@ class WebConsolePlugin extends SimpleWeb
         }
     }
 
-    void disabledComponent(final JSONWriter jw, final ComponentDescriptionDTO desc, boolean details)
+    void component(JSONWriter jw,
+            final ComponentDescriptionDTO desc,
+            final ComponentConfigurationDTO config, boolean details)
     {
-        final String name = desc.name;
+        String id = config == null ? "" : String.valueOf(config.id);
+        String name = desc.name;
 
         jw.object();
 
         // component information
         jw.key("id"); //$NON-NLS-1$
-        jw.value("");
+        jw.value(id);
+        jw.key("bundleId"); //$NON-NLS-1$
+        jw.value(desc.bundle.id);
         jw.key("name"); //$NON-NLS-1$
         jw.value(name);
         jw.key("state"); //$NON-NLS-1$
-        if ( desc.defaultEnabled && "require".equals(desc.configurationPolicy))
+        if ( config != null )
         {
-            jw.value("no config");
+            jw.value(ComponentConfigurationPrinter.toStateString(config.state));
+            jw.key("stateRaw"); //$NON-NLS-1$
+            jw.value(config.state);
         }
         else
         {
-            jw.value("disabled"); //$NON-NLS-1$
+            if ( desc.defaultEnabled && "require".equals(desc.configurationPolicy))
+            {
+                jw.value("no config");
+            }
+            else
+            {
+                jw.value("disabled"); //$NON-NLS-1$
+            }
+            jw.key("stateRaw"); //$NON-NLS-1$
+            jw.value(-1);
         }
-        jw.key("stateRaw"); //$NON-NLS-1$
-        jw.value(-1);
 
         writePid(jw, desc);
 
-        if (details)
-        {
-            gatherComponentDetails(jw, desc, null);
-        }
-
-        jw.endObject();
-    }
-
-    void component(JSONWriter jw, ComponentConfigurationDTO config, boolean details)
-    {
-        String id = String.valueOf(config.id);
-        String name = config.description.name;
-
-        jw.object();
-
-        // component information
-        jw.key("id"); //$NON-NLS-1$
-        jw.value(id);
-        jw.key("name"); //$NON-NLS-1$
-        jw.value(name);
-        jw.key("state"); //$NON-NLS-1$
-        jw.value(ComponentConfigurationPrinter.toStateString(config.state));
-        jw.key("stateRaw"); //$NON-NLS-1$
-        jw.value(config.state);
-
-        writePid(jw, config.description);
-
         // component details
         if (details)
         {
-            gatherComponentDetails(jw, config.description, config);
+            gatherComponentDetails(jw, desc, config);
         }
 
         jw.endObject();
@@ -689,10 +676,29 @@ class WebConsolePlugin extends SimpleWeb
                 final int slash = names.lastIndexOf('/');
                 final String componentName;
                 final String pid;
+                long bundleId = -1;
                 if (slash > 0)
                 {
-                    componentName = names.substring(0, slash);
                     pid = names.substring(slash + 1);
+                    final String firstPart = names.substring(0, slash);
+                    final int bundleIndex = firstPart.indexOf('/');
+                    if ( bundleIndex == -1 )
+                    {
+                        componentName = firstPart;
+                    }
+                    else
+                    {
+                        componentName = firstPart.substring(bundleIndex + 1);
+                        try
+                        {
+                            bundleId = Long.valueOf(firstPart.substring(0, bundleIndex));
+                        }
+                        catch ( final NumberFormatException nfe)
+                        {
+                            // wrong format
+                            return null;
+                        }
+                    }
                 }
                 else
                 {
@@ -703,7 +709,7 @@ class WebConsolePlugin extends SimpleWeb
                 Collection<ComponentConfigurationDTO> components = null;
                 for(final ComponentDescriptionDTO d : this.descriptions)
                 {
-                    if ( d.name.equals(componentName) )
+                    if ( d.name.equals(componentName) && (bundleId == -1 || d.bundle.id == bundleId))
                     {
                         components = scrService.getComponentConfigurationDTOs(d);
                         if ( components.isEmpty() )

Modified: felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.js?rev=1779210&r1=1779209&r2=1779210&view=diff
==============================================================================
--- felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.js (original)
+++ felix/trunk/webconsole-plugins/ds/src/main/resources/res/plugin.js Tue Jan 17 16:38:08 2017
@@ -40,7 +40,7 @@ function renderData( eventData )  {
 function getEntryId(/* Object */ dataEntry) {
     var id = dataEntry.id;
     if (id == null || id < 0 || id === "") {
-        id = dataEntry.name;
+        id = dataEntry.bundleId + '/' + dataEntry.name;
         if (dataEntry.pid) {
             id += '/' + dataEntry.pid;
         }