directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r808108 - in /directory: apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/ shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/
Date Wed, 26 Aug 2009 16:27:22 GMT
Author: elecharny
Date: Wed Aug 26 16:27:22 2009
New Revision: 808108

URL: http://svn.apache.org/viewvc?rev=808108&view=rev
Log:
o Removed the ObjectClassImpl class
o Added the applyRegistries() method to ObjectClass

Modified:
    directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
    directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java

Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java?rev=808108&r1=808107&r2=808108&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
Wed Aug 26 16:27:22 2009
@@ -41,8 +41,6 @@
 import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.LdapSyntax;
-import org.apache.directory.shared.ldap.schema.parsers.AbstractSchemaDescription;
-import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescription;
 import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescriptionSchemaParser;
 import org.apache.directory.shared.ldap.schema.parsers.LdapComparatorDescription;
 import org.apache.directory.shared.ldap.schema.parsers.LdapComparatorDescriptionSchemaParser;
@@ -54,7 +52,6 @@
 import org.apache.directory.shared.ldap.schema.parsers.NameFormDescriptionSchemaParser;
 import org.apache.directory.shared.ldap.schema.parsers.NormalizerDescription;
 import org.apache.directory.shared.ldap.schema.parsers.NormalizerDescriptionSchemaParser;
-import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescription;
 import org.apache.directory.shared.ldap.schema.parsers.ObjectClassDescriptionSchemaParser;
 import org.apache.directory.shared.ldap.schema.parsers.SyntaxCheckerDescription;
 import org.apache.directory.shared.ldap.schema.parsers.SyntaxCheckerDescriptionSchemaParser;
@@ -72,7 +69,6 @@
 public class DescriptionParsers
 {
     private static final String OTHER_SCHEMA = "other";
-    private static final String[] EMPTY = new String[0];
 
     private static final LdapComparatorDescription[] EMPTY_COMPARATORS = new LdapComparatorDescription[0];
     private static final NormalizerDescription[] EMPTY_NORMALIZERS = new NormalizerDescription[0];
@@ -241,11 +237,11 @@
         
         for ( Value<?> value:attr )
         {
-            AttributeTypeDescription desc = null;
+            AttributeType attributeType = null;
             
             try
             {
-                desc = attributeTypeParser.parseAttributeTypeDescription( value.getString()
);
+                attributeType = attributeTypeParser.parseAttributeTypeDescription( value.getString()
);
             }
             catch ( ParseException e )
             {
@@ -257,62 +253,64 @@
             }
 
             // if the supertype is provided make sure it exists in some schema
-            if ( desc.getSuperType() != null && ! dao.hasAttributeType( desc.getSuperType()
) )
+            if ( attributeType.getSupOid() != null && ! dao.hasAttributeType( attributeType.getSupOid()
) )
             {
                 throw new LdapOperationNotSupportedException(
                     "Cannot permit the addition of an attributeType with an invalid super
type: " 
-                        + desc.getSuperType(), 
+                        + attributeType.getSupOid(), 
                     ResultCodeEnum.UNWILLING_TO_PERFORM );
             }
 
             // if the syntax is provided by the description make sure it exists in some schema
-            if ( desc.getSyntax() != null && ! dao.hasSyntax( desc.getSyntax() )
)
+            if ( attributeType.getSyntax() != null && ! dao.hasSyntax( attributeType.getSyntaxOid()
) )
             {
                 throw new LdapOperationNotSupportedException(
-                    "Cannot permit the addition of an attributeType with an invalid syntax:
" + desc.getSyntax(), 
+                    "Cannot permit the addition of an attributeType with an invalid syntax:
" + 
+                    attributeType.getSyntaxOid(), 
                     ResultCodeEnum.UNWILLING_TO_PERFORM );
             }
             
             // if the matchingRule is provided make sure it exists in some schema
-            if ( desc.getEqualityMatchingRule() != null && ! dao.hasMatchingRule(
desc.getEqualityMatchingRule() ) )
+            if ( attributeType.getEqualityOid() != null && ! dao.hasMatchingRule(
attributeType.getEqualityOid() ) )
             {
                 throw new LdapOperationNotSupportedException(
                     "Cannot permit the addition of an attributeType with an invalid EQUALITY
matchingRule: " 
-                        + desc.getEqualityMatchingRule(), 
+                        + attributeType.getEqualityOid(), 
                     ResultCodeEnum.UNWILLING_TO_PERFORM );
             }
 
             // if the matchingRule is provided make sure it exists in some schema
-            if ( desc.getOrderingMatchingRule() != null && ! dao.hasMatchingRule(
desc.getOrderingMatchingRule() ) )
+            if ( attributeType.getOrderingOid() != null && ! dao.hasMatchingRule(
attributeType.getOrderingOid() ) )
             {
                 throw new LdapOperationNotSupportedException(
                     "Cannot permit the addition of an attributeType with an invalid ORDERING
matchingRule: " 
-                        + desc.getOrderingMatchingRule(), 
+                        + attributeType.getOrderingOid(), 
                     ResultCodeEnum.UNWILLING_TO_PERFORM );
             }
 
             // if the matchingRule is provided make sure it exists in some schema
-            if ( desc.getSubstringsMatchingRule() != null && ! dao.hasMatchingRule(
desc.getSubstringsMatchingRule() ) )
+            if ( attributeType.getSubstrOid() != null && ! dao.hasMatchingRule( attributeType.getSubstrOid()
) )
             {
                 throw new LdapOperationNotSupportedException(
                     "Cannot permit the addition of an attributeType with an invalid SUBSTRINGS
matchingRule: " 
-                        + desc.getSubstringsMatchingRule(), 
+                        + attributeType.getSubstrOid(), 
                     ResultCodeEnum.UNWILLING_TO_PERFORM );
             }
 
             // if the equality matching rule is null and no super type is specified then
there is
             // definitely no equality matchingRule that can be resolved.  We cannot use an
attribute
             // without a matchingRule for search or for building indices not to mention lookups.
-            if ( desc.getEqualityMatchingRule() == null && desc.getSuperType() ==
null )
+            if ( attributeType.getEqualityOid() == null && attributeType.getSupOid()
== null )
             {
                 throw new LdapOperationNotSupportedException(
                     "Cannot permit the addition of an attributeType with an no EQUALITY matchingRule
" +
                     "\nand no super type from which to derive an EQUALITY matchingRule.",

                     ResultCodeEnum.UNWILLING_TO_PERFORM );
             }
-            else if ( desc.getEqualityMatchingRule() == null )
+            else if ( attributeType.getEqualityOid() == null )
             {
-                AttributeType superType = globalRegistries.getAttributeTypeRegistry().lookup(
desc.getSuperType() );
+                AttributeType superType = globalRegistries.getAttributeTypeRegistry().lookup(
attributeType.getSupOid() );
+
                 if ( superType.getEquality() == null )
                 {
                     throw new LdapOperationNotSupportedException(
@@ -326,7 +324,7 @@
             // must be provided from some ancestor in the attributeType hierarchy; without
either
             // of these the description definitely cannot resolve a syntax and cannot be
allowed.
             // if a supertype exists then it must resolve a proper syntax somewhere in the
hierarchy.
-            if ( desc.getSyntax() == null && desc.getSuperType() == null )
+            if ( attributeType.getSyntax() == null && attributeType.getSupOid() ==
null )
             {
                 throw new LdapOperationNotSupportedException(
                     "Cannot permit the addition of an attributeType with an no syntax " +
@@ -335,20 +333,10 @@
             }
             
 
-            AttributeType at = new AttributeType( desc.getNumericOid() );
-            at.setCanUserModify( desc.isUserModifiable() );
-            at.setCollective( desc.isCollective() );
-            at.setEqualityOid( desc.getEqualityMatchingRule() );
-            at.setOrderingOid( desc.getOrderingMatchingRule() );
-            at.setSingleValue( desc.isSingleValued() );
-            at.setSubstrOid( desc.getSubstringsMatchingRule() );
-            at.setSuperiorOid( desc.getSuperType() );
-            at.setSyntaxOid( desc.getSyntax() );
-            at.setUsage( desc.getUsage() );
-            
+            AttributeType at = new AttributeType( attributeType.getOid() );
             at.applyRegistries( globalRegistries );
             
-            setSchemaObjectProperties( desc, at );
+            setSchemaObjectProperties( attributeType, at );
 
             attributeTypes[pos++] = at;
         }
@@ -378,11 +366,11 @@
         
         for ( Value<?> value:attr )
         {
-            ObjectClassDescription desc = null;
+            ObjectClass objectClass = null;
             
             try
             {
-                desc = objectClassParser.parseObjectClassDescription( value.getString() );
+                objectClass = objectClassParser.parseObjectClassDescription( value.getString()
);
             }
             catch ( ParseException e )
             {
@@ -394,9 +382,9 @@
             }
             
             // if the super objectClasses are provided make sure it exists in some schema
-            if ( desc.getSuperiorObjectClasses() != null && desc.getSuperiorObjectClasses().size()
> 0 )
+            if ( objectClass.getSuperiorOids() != null && objectClass.getSuperiorOids().size()
> 0 )
             {
-                for ( String superior : desc.getSuperiorObjectClasses() )
+                for ( String superior : objectClass.getSuperiorOids() )
                 {
                     if ( superior.equals( SchemaConstants.TOP_OC_OID ) || 
                         superior.equalsIgnoreCase( SchemaConstants.TOP_OC ) )
@@ -415,9 +403,9 @@
             }
             
             // if the may list is provided make sure attributes exists in some schema
-            if ( desc.getMayAttributeTypes() != null && desc.getMayAttributeTypes().size()
> 0 )
+            if ( objectClass.getMayAttributeTypeOids() != null && objectClass.getMayAttributeTypeOids().size()
> 0 )
             {
-                for ( String mayAttr : desc.getMayAttributeTypes() )
+                for ( String mayAttr : objectClass.getMayAttributeTypeOids() )
                 {
                     if ( ! dao.hasAttributeType( mayAttr ) )
                     {
@@ -430,9 +418,9 @@
             }
             
             // if the must list is provided make sure attributes exists in some schema
-            if ( desc.getMustAttributeTypes() != null && desc.getMustAttributeTypes().size()
> 0 )
+            if ( objectClass.getMustAttributeTypeOids() != null && objectClass.getMustAttributeTypeOids().size()
> 0 )
             {
-                for ( String mustAttr : desc.getMustAttributeTypes() )
+                for ( String mustAttr : objectClass.getMustAttributeTypeOids() )
                 {
                     if ( ! dao.hasAttributeType( mustAttr ) )
                     {
@@ -444,12 +432,8 @@
                 }
             }
             
-            ObjectClassImpl oc = new ObjectClassImpl( desc.getNumericOid(), globalRegistries
);
-            oc.setMayListOids( desc.getMayAttributeTypes().toArray( EMPTY) );
-            oc.setMustListOids( desc.getMustAttributeTypes().toArray( EMPTY ) );
-            oc.setSuperClassOids( desc.getSuperiorObjectClasses().toArray( EMPTY ) );
-            oc.setType( desc.getKind() );
-            setSchemaObjectProperties( desc, oc );
+            ObjectClass oc = new ObjectClass( objectClass.getOid() );
+            oc.applyRegistries( globalRegistries );
             
             objectClasses[pos++] = oc;
         }

Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java?rev=808108&r1=808107&r2=808108&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
Wed Aug 26 16:27:22 2009
@@ -22,7 +22,6 @@
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Comparator;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -70,7 +69,8 @@
     /** Used for looking up the setSyntaxOid(String) method */
     private final static Class<?>[] setOidParameterTypes = new Class[] { String.class
};
     
-    private static final String[] EMPTY = new String[0];
+    private static final List<String> EMPTY_LIST = new ArrayList<String>();
+    private static final String[] EMPTY_ARRAY = new String[] {};
     
     /** Used for dependency injection of Registries via setter into schema objects */
     private final Registries bootstrapRegistries;
@@ -93,7 +93,7 @@
     {
         String name;
         String owner;
-        String[] dependencies = EMPTY;
+        String[] dependencies = EMPTY_ARRAY;
         boolean isDisabled = false;
         
         if ( entry == null )
@@ -133,7 +133,7 @@
                 depsSet.add( value.getString() );
             }
 
-            dependencies = depsSet.toArray( EMPTY );
+            dependencies = depsSet.toArray( EMPTY_ARRAY );
         }
         
         return new AbstractSchema( name, owner, dependencies, isDisabled ){};
@@ -576,26 +576,24 @@
         MatchingRule mr = new MatchingRule( oid );
         mr.setSyntaxOid( syntaxOid );
         mr.setSchemaName( schema );
-        mr.setRegistries(  targetRegistries );
+        mr.applyRegistries( targetRegistries );
         setSchemaObjectProperties( mr, entry );
         return mr;
     }
     
     
-    private String[] getStrings( EntryAttribute attr ) throws NamingException
+    private List<String> getStrings( EntryAttribute attr ) throws NamingException
     {
         if ( attr == null )
         {
-            return EMPTY;
+            return EMPTY_LIST;
         }
         
-        String[] strings = new String[attr.size()];
-        
-        int pos = 0;
+        List<String> strings = new ArrayList<String>( attr.size() );
         
         for ( Value<?> value:attr )
         {
-            strings[pos++] = value.getString();
+            strings.add( value.getString() );
         }
         
         return strings;
@@ -605,22 +603,23 @@
     public ObjectClass getObjectClass( ServerEntry entry, Registries targetRegistries, String
schema ) throws NamingException
     {
         String oid = entry.get( MetaSchemaConstants.M_OID_AT ).getString();
-        ObjectClassImpl oc = new ObjectClassImpl( oid, targetRegistries );
-        oc.setSchema( schema );
+        ObjectClass oc = new ObjectClass( oid );
+        oc.applyRegistries( targetRegistries );
+        oc.setSchemaName( schema );
         
         if ( entry.get( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT ) != null )
         {
-            oc.setSuperClassOids( getStrings( entry.get( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT
) ) );
+            oc.setSuperiorOids( getStrings( entry.get( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT
) ) );
         }
         
         if ( entry.get( MetaSchemaConstants.M_MAY_AT ) != null )
         {
-            oc.setMayListOids( getStrings( entry.get( MetaSchemaConstants.M_MAY_AT ) ) );
+            oc.setMayAttributeTypeOids( getStrings( entry.get( MetaSchemaConstants.M_MAY_AT
) ) );
         }
         
         if ( entry.get( MetaSchemaConstants.M_MUST_AT ) != null )
         {
-            oc.setMustListOids( getStrings( entry.get( MetaSchemaConstants.M_MUST_AT ) )
);
+            oc.setMustAttributeTypeOids( getStrings( entry.get( MetaSchemaConstants.M_MUST_AT
) ) );
         }
         
         if ( entry.get( MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT ) != null )

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java?rev=808108&r1=808107&r2=808108&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
Wed Aug 26 16:27:22 2009
@@ -25,6 +25,10 @@
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+
 
 /**
  * An objectClass definition.
@@ -111,6 +115,52 @@
         mustAttributeTypes = new ArrayList<AttributeType>();
         superiors = new ArrayList<ObjectClass>();
     }
+    
+    
+    /**
+     * Inject the registries into this Object, updating the references to
+     * other SchemaObject
+     *
+     * @param registries The Registries
+     */
+    public void applyRegistries( Registries registries ) throws NamingException
+    {
+        if ( registries != null )
+        {
+            AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
+            ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
+            
+            if ( superiorOids != null )
+            {
+                superiors = new ArrayList<ObjectClass>( superiorOids.size() );
+                
+                for ( String oid : superiorOids )
+                {
+                    superiors.add( ocRegistry.lookup( oid ) );
+                }
+            }
+
+            if ( mayAttributeTypeOids != null )
+            {
+                mayAttributeTypes = new ArrayList<AttributeType>( mayAttributeTypeOids.size()
);
+                
+                for ( String oid : mayAttributeTypeOids )
+                {
+                    mayAttributeTypes.add( atRegistry.lookup( oid ) );
+                }
+            }
+
+            if ( mustAttributeTypeOids != null )
+            {
+                mustAttributeTypes = new ArrayList<AttributeType>( mustAttributeTypeOids.size()
);
+                
+                for ( String oid : mustAttributeTypeOids )
+                {
+                    mustAttributeTypes.add( atRegistry.lookup( oid ) );
+                }
+            }
+        }
+    }
 
     
     /**



Mime
View raw message