You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by fm...@apache.org on 2011/03/24 17:09:57 UTC

svn commit: r1085018 - in /felix/trunk/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium: ConfigManager.java ConfigManagerBase.java

Author: fmeschbe
Date: Thu Mar 24 16:09:57 2011
New Revision: 1085018

URL: http://svn.apache.org/viewvc?rev=1085018&view=rev
Log:
FELIX-1865 Fix wrong assumption of the OCD ID being the same as the PID (or factory PID)

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

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=1085018&r1=1085017&r2=1085018&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 Thu Mar 24 16:09:57 2011
@@ -22,13 +22,13 @@ import java.io.IOException;
 import java.io.PrintWriter;
 import java.lang.reflect.Array;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.Dictionary;
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Properties;
 import java.util.SortedMap;
 import java.util.StringTokenizer;
@@ -504,7 +504,7 @@ public class ConfigManager extends Confi
     }
 
 
-    private void addMetaTypeNames( final Map pidMap, final Collection ocdCollection, final String filterSpec, final String type )
+    private void addMetaTypeNames( final Map pidMap, final Map ocdCollection, final String filterSpec, final String type )
     {
         Filter filter = null;
         if ( filterSpec != null )
@@ -519,16 +519,24 @@ public class ConfigManager extends Confi
             }
         }
 
-        for ( Iterator oci = ocdCollection.iterator(); oci.hasNext(); )
+        for ( Iterator oci = ocdCollection.entrySet().iterator(); oci.hasNext(); )
         {
-            final ObjectClassDefinition ocd = ( ObjectClassDefinition ) oci.next();
-            final String pid = ocd.getID();
-            final Dictionary props = new Hashtable();
-            props.put( type, pid );
-            if ( filter == null || filter.match( props ) )
+            final Entry ociEntry = (Entry) oci.next();
+            final String pid = (String) ociEntry.getKey();
+            final ObjectClassDefinition ocd = ( ObjectClassDefinition ) ociEntry.getValue();
+            if ( filter == null )
             {
                 pidMap.put( pid, ocd.getName() );
             }
+            else
+            {
+                final Dictionary props = new Hashtable();
+                props.put( type, pid );
+                if ( filter.match( props ) )
+                {
+                    pidMap.put( pid, ocd.getName() );
+                }
+            }
         }
 
     }

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=1085018&r1=1085017&r2=1085018&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 Thu Mar 24 16:09:57 2011
@@ -17,8 +17,6 @@
 package org.apache.felix.webconsole.internal.compendium;
 
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.Locale;
 import java.util.Map;
@@ -75,11 +73,11 @@ abstract class ConfigManagerBase extends
      * the MetaType information for that PID.
      *
      * @param locale The name of the locale to get the meta data for.
-     * @return see the method description 
+     * @return see the method description
      */
-    protected Collection getPidObjectClasses( final String locale )
+    protected Map getPidObjectClasses( final String locale )
     {
-        return getObjectClasses( PID_GETTER, locale );
+        return getObjectClassDefinitions( PID_GETTER, locale );
     }
 
 
@@ -90,11 +88,11 @@ abstract class ConfigManagerBase extends
      * PID.
      *
      * @param locale The name of the locale to get the meta data for.
-     * @return see the method description 
+     * @return see the method description
      */
-    protected Collection getFactoryPidObjectClasses( final String locale )
+    protected Map getFactoryPidObjectClasses( final String locale )
     {
-        return getObjectClasses( FACTORY_PID_GETTER, locale );
+        return getObjectClassDefinitions( FACTORY_PID_GETTER, locale );
     }
 
 
@@ -108,10 +106,12 @@ abstract class ConfigManagerBase extends
      *          or PIDs from <code>MetaTypeInformation</code> objects.
      * @param locale The name of the locale to get the object class definitions
      *          for.
+     * @return Map of <code>ObjectClassDefinition</code> objects indexed by the
+     *      PID (or factory PID) to which they pertain
      */
-    private Collection getObjectClasses( final IdGetter idGetter, final String locale )
+    private Map getObjectClassDefinitions( final IdGetter idGetter, final String locale )
     {
-        final Collection objectClasses = new ArrayList();
+        final Map objectClassesDefinitions = new HashMap();
         final MetaTypeService mts = this.getMetaTypeService();
         if ( mts != null )
         {
@@ -124,13 +124,13 @@ abstract class ConfigManagerBase extends
                     final String[] idList = idGetter.getIds( mti );
                     for ( int j = 0; idList != null && j < idList.length; j++ )
                     {
-                        // After getting the list of PIDs, a configuration  might be 
+                        // After getting the list of PIDs, a configuration  might be
                         // removed. So the getObjectClassDefinition will throw
                         // an exception, and this will prevent ALL configuration from
                         // being displayed. By catching it, the configurations will be
                         // visible
                         ObjectClassDefinition ocd = null;
-                        try 
+                        try
                         {
                             ocd = mti.getObjectClassDefinition( idList[j], locale );
                         }
@@ -140,13 +140,13 @@ abstract class ConfigManagerBase extends
                         }
                         if ( ocd != null )
                         {
-                            objectClasses.add( ocd );
+                            objectClassesDefinitions.put( idList[j], ocd );
                         }
                     }
                 }
             }
         }
-        return objectClasses;
+        return objectClassesDefinitions;
     }