felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r829261 - in /felix/trunk/webconsole/src/main: java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java resources/res/ui/configmanager.js
Date Fri, 23 Oct 2009 22:15:55 GMT
Author: fmeschbe
Date: Fri Oct 23 22:15:54 2009
New Revision: 829261

URL: http://svn.apache.org/viewvc?rev=829261&view=rev
Log:
FELIX-1800: Multiple related fixes:
  - list all configurations in the drop down, even such without metatype information
  - prevent NullPointerException rendering configuration binding information if
    no bundle with the bound location is installed
  - properly attach the generic configuration property entry to the parent element
  - ask all bundles for metatype information of a configuration if no bundle
    is installed whose bundle location equals the configuration binding

Modified:
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
    felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
    felix/trunk/webconsole/src/main/resources/res/ui/configmanager.js

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java?rev=829261&r1=829260&r2=829261&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManager.java
Fri Oct 23 22:15:54 2009
@@ -373,7 +373,7 @@
         {
             // start with ManagedService instances
             SortedMap optionsPlain = getServices( ManagedService.class.getName(), pidFilter,
locale, true );
-            
+
             // next are the MetaType informations without ManagedService
             addMetaTypeNames( optionsPlain, getPidObjectClasses( locale ), pidFilter, Constants.SERVICE_PID
);
 
@@ -403,10 +403,7 @@
                     name = pid;
                 }
 
-                if ( ocd != null )
-                {
-                    optionsPlain.put( pid, name );
-                }
+                optionsPlain.put( pid, name );
             }
 
             printOptionsForm( pw, optionsPlain, "configSelection_pid", "configure", "Configure"
);
@@ -758,21 +755,30 @@
         }
         else
         {
+            // if the configuration is bound to a bundle location which
+            // is not related to an installed bundle, we just print the
+            // raw bundle location binding
             Bundle bundle = this.getBundle( config.getBundleLocation() );
-
-            Dictionary headers = bundle.getHeaders( locale );
-            String name = ( String ) headers.get( Constants.BUNDLE_NAME );
-            if ( name == null )
+            if ( bundle == null )
             {
-                location = bundle.getSymbolicName();
+                location = config.getBundleLocation();
             }
             else
             {
-                location = name + " (" + bundle.getSymbolicName() + ")";
-            }
+                Dictionary headers = bundle.getHeaders( locale );
+                String name = ( String ) headers.get( Constants.BUNDLE_NAME );
+                if ( name == null )
+                {
+                    location = bundle.getSymbolicName();
+                }
+                else
+                {
+                    location = name + " (" + bundle.getSymbolicName() + ")";
+                }
 
-            Version v = Version.parseVersion( ( String ) headers.get( Constants.BUNDLE_VERSION
) );
-            location += ", Version " + v.toString();
+                Version v = Version.parseVersion( ( String ) headers.get( Constants.BUNDLE_VERSION
) );
+                location += ", Version " + v.toString();
+            }
         }
         json.key( "bundleLocation" );
         json.value( location );

Modified: felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java?rev=829261&r1=829260&r2=829261&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
(original)
+++ felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
Fri Oct 23 22:15:54 2009
@@ -91,7 +91,7 @@
      * returned by the <code>idGetter</code>. Depending on the
      * <code>idGetter</code> implementation this will be for factory PIDs or
      * plain PIDs.
-     * 
+     *
      * @param idGetter The {@link IdGetter} used to get the list of factory PIDs
      *          or PIDs from <code>MetaTypeInformation</code> objetcs.
      * @param locale The name of the locale to get the object class definitions
@@ -127,43 +127,43 @@
 
     protected ObjectClassDefinition getObjectClassDefinition( Configuration config, String
locale )
     {
-
-        // if the configuration is not bound, search in the bundles
-        if ( config.getBundleLocation() == null )
-        {
-            // if the configuration is a factory one, use the factory PID
-            if ( config.getFactoryPid() != null )
-            {
-                return this.getObjectClassDefinition( config.getFactoryPid(), locale );
-            }
-
-            // otherwise use the configuration PID
-            return this.getObjectClassDefinition( config.getPid(), locale );
-        }
-
-        MetaTypeService mts = this.getMetaTypeService();
-        if ( mts != null )
+        // if the configuration is bound, try to get the object class
+        // definition from the bundle installed from the given location
+        if ( config.getBundleLocation() != null )
         {
             Bundle bundle = this.getBundle( config.getBundleLocation() );
             if ( bundle != null )
             {
-                MetaTypeInformation mti = mts.getMetaTypeInformation( bundle );
-                if ( mti != null )
+                MetaTypeService mts = this.getMetaTypeService();
+                if ( mts != null )
                 {
-                    // check by factory PID
-                    if ( config.getFactoryPid() != null )
+                    MetaTypeInformation mti = mts.getMetaTypeInformation( bundle );
+                    if ( mti != null )
                     {
-                        return mti.getObjectClassDefinition( config.getFactoryPid(), locale
);
-                    }
+                        // check by factory PID
+                        if ( config.getFactoryPid() != null )
+                        {
+                            return mti.getObjectClassDefinition( config.getFactoryPid(),
locale );
+                        }
 
-                    // otherwise check by configuration PID
-                    return mti.getObjectClassDefinition( config.getPid(), locale );
+                        // otherwise check by configuration PID
+                        return mti.getObjectClassDefinition( config.getPid(), locale );
+                    }
                 }
             }
         }
 
-        // fallback to nothing found
-        return null;
+        // get here if the configuration is not bound or if no
+        // bundle with the bound location is installed. We search
+        // all bundles for a matching [factory] PID
+        // if the configuration is a factory one, use the factory PID
+        if ( config.getFactoryPid() != null )
+        {
+            return this.getObjectClassDefinition( config.getFactoryPid(), locale );
+        }
+
+        // otherwise use the configuration PID
+        return this.getObjectClassDefinition( config.getPid(), locale );
     }
 
 
@@ -269,7 +269,7 @@
      * The <code>IdGetter</code> interface is an internal helper to abstract
      * retrieving object class definitions from all bundles for either
      * pids or factory pids.
-     * 
+     *
      * @see #PID_GETTER
      * @see #FACTORY_PID_GETTER
      */
@@ -278,10 +278,10 @@
         String[] getIds( MetaTypeInformation metaTypeInformation );
     }
 
-    /** 
+    /**
      * The implementation of the {@link IdGetter} interface returning the PIDs
      * listed in the meta type information.
-     * 
+     *
      * @see #getPidObjectClasses(String)
      */
     private static final IdGetter PID_GETTER = new IdGetter()
@@ -292,10 +292,10 @@
         }
     };
 
-    /** 
+    /**
      * The implementation of the {@link IdGetter} interface returning the
      * factory PIDs listed in the meta type information.
-     * 
+     *
      * @see #getFactoryPidObjectClasses(String)
      */
     private static final IdGetter FACTORY_PID_GETTER = new IdGetter()

Modified: felix/trunk/webconsole/src/main/resources/res/ui/configmanager.js
URL: http://svn.apache.org/viewvc/felix/trunk/webconsole/src/main/resources/res/ui/configmanager.js?rev=829261&r1=829260&r2=829261&view=diff
==============================================================================
--- felix/trunk/webconsole/src/main/resources/res/ui/configmanager.js (original)
+++ felix/trunk/webconsole/src/main/resources/res/ui/configmanager.js Fri Oct 23 22:15:54
2009
@@ -173,18 +173,20 @@
         propsValue += key + ' =  ' + props[key] + '\r\n';
     }
 
-    return tr( "content", null, [
-        td( "content aligntop", null, [
-            text( "Properties" )
-        ]),
-        td( "content", { style: { width: "99%" } }, [
-            createElement( "textarea", null, {
-                    name: "properties",
-                    style: { height: "50%", width: "99%" }
-                }, [ text( propsValue ) ] ),
-            text( "Enter Name-Value pairs of configuration properties" )
+    parent.appendChild(
+        tr( "content", null, [
+            td( "content aligntop", null, [
+                text( "Properties" )
+            ]),
+            td( "content", { style: { width: "99%" } }, [
+                createElement( "textarea", null, {
+                        name: "properties",
+                        style: { height: "50%", width: "99%" }
+                    }, [ text( propsValue ) ] ),
+                text( "Enter Name-Value pairs of configuration properties" )
+            ])
         ])
-    ]);        
+    );        
 }
 
 function printForm( /* Element */ parent, obj ) {



Mime
View raw message