FELIX-2096 Throw IllegalArgumentException if id is empty or null or if no localized ObjectClassDefinition can be found. Thus the result of getObjectClassDefinition will now never be null

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1187706 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java b/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
index c743230..f1fd44c 100644
--- a/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
+++ b/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
@@ -121,8 +121,25 @@
      */
     public ObjectClassDefinition getObjectClassDefinition(String id,
             String locale) {
-        MetaTypeProvider mtp = (MetaTypeProvider) this.metaTypeProviders.get(id);
-        return (mtp != null) ? mtp.getObjectClassDefinition(id, locale) : null;
+
+        if ( id == null || id.length() == 0 )
+        {
+            throw new IllegalArgumentException( "ObjectClassDefinition ID must not be null or empty" );
+        }
+
+        MetaTypeProvider mtp = ( MetaTypeProvider ) this.metaTypeProviders.get( id );
+        if ( mtp == null )
+        {
+            throw new IllegalArgumentException( "No ObjectClassDefinition for id=" + id );
+        }
+
+        ObjectClassDefinition ocd = mtp.getObjectClassDefinition( id, locale );
+        if ( ocd == null )
+        {
+            throw new IllegalArgumentException( "No localized ObjectClassDefinition for id=" + id );
+        }
+
+        return ocd;
     }
 
     // ---------- internal support for metadata -------------------------------