FELIX-1865 Fix wrong assumption of the OCD ID being the same as the PID (or factory PID)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1085018 13f79535-47bb-0310-9956-ffa450edef68
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 52aa22b..52f3c0f 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
@@ -22,13 +22,13 @@
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 @@
}
- 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 @@
}
}
- 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() );
+ }
+ }
}
}
diff --git a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
index 493ff99..525dd2e 100644
--- a/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
+++ b/webconsole/src/main/java/org/apache/felix/webconsole/internal/compendium/ConfigManagerBase.java
@@ -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 @@
* 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 @@
* 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 @@
* 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 @@
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 @@
}
if ( ocd != null )
{
- objectClasses.add( ocd );
+ objectClassesDefinitions.put( idList[j], ocd );
}
}
}
}
}
- return objectClasses;
+ return objectClassesDefinitions;
}