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/10/22 14:36:06 UTC

svn commit: r1187706 - /felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java

Author: fmeschbe
Date: Sat Oct 22 12:36:06 2011
New Revision: 1187706

URL: http://svn.apache.org/viewvc?rev=1187706&view=rev
Log:
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

Modified:
    felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java

Modified: felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java?rev=1187706&r1=1187705&r2=1187706&view=diff
==============================================================================
--- felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java (original)
+++ felix/trunk/metatype/src/main/java/org/apache/felix/metatype/internal/MetaTypeInformationImpl.java Sat Oct 22 12:36:06 2011
@@ -121,8 +121,25 @@ public class MetaTypeInformationImpl imp
      */
     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 -------------------------------