directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 55796 - in incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema: . bootstrap
Date Thu, 28 Oct 2004 08:06:13 GMT
Author: akarasulu
Date: Thu Oct 28 01:06:12 2004
New Revision: 55796

Added:
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalRegistries.java
Modified:
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalAttributeTypeRegistry.java
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalMatchingRuleRegistry.java
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalObjectClassRegistry.java
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalSyntaxRegistry.java
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapMatchingRuleRegistry.java
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapObjectClassRegistry.java
   incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapSyntaxRegistry.java
Log:
Changes ...

 o added new GlobalRegistries implementation of Registries
 o made changes to accomodate need for public list methods



Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalAttributeTypeRegistry.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalAttributeTypeRegistry.java
(original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalAttributeTypeRegistry.java
Thu Oct 28 01:06:12 2004
@@ -193,7 +193,6 @@
     }
 
 
-
     public Iterator list()
     {
         return new JoinIterator( new Iterator[]

Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalMatchingRuleRegistry.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalMatchingRuleRegistry.java
(original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalMatchingRuleRegistry.java
Thu Oct 28 01:06:12 2004
@@ -19,9 +19,11 @@
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Iterator;
 import javax.naming.NamingException;
 
 import org.apache.ldap.common.schema.MatchingRule;
+import org.apache.ldap.common.util.JoinIterator;
 
 import org.apache.eve.SystemPartition;
 import org.apache.eve.schema.bootstrap.BootstrapMatchingRuleRegistry;
@@ -173,5 +175,12 @@
 
         throw new NamingException( "OID " + id + " not found in oid to " +
             "schema name map!" );
+    }
+
+
+    public Iterator list()
+    {
+        return new JoinIterator( new Iterator[]
+            { byOid.values().iterator(),bootstrap.list() } );
     }
 }

Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalObjectClassRegistry.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalObjectClassRegistry.java
(original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalObjectClassRegistry.java
Thu Oct 28 01:06:12 2004
@@ -19,9 +19,11 @@
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Iterator;
 import javax.naming.NamingException;
 
 import org.apache.ldap.common.schema.ObjectClass;
+import org.apache.ldap.common.util.JoinIterator;
 
 import org.apache.eve.SystemPartition;
 import org.apache.eve.schema.bootstrap.BootstrapObjectClassRegistry;
@@ -173,5 +175,12 @@
 
         throw new NamingException( "OID " + id + " not found in oid to " +
             "schema name map!" );
+    }
+
+
+    public Iterator list()
+    {
+        return new JoinIterator( new Iterator[]
+            { byOid.values().iterator(),bootstrap.list() } );
     }
 }

Added: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalRegistries.java
==============================================================================
--- (empty file)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalRegistries.java
Thu Oct 28 01:06:12 2004
@@ -0,0 +1,468 @@
+/*
+ *   Copyright 2004 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.eve.schema;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.NamingException;
+
+import org.apache.ldap.common.schema.ObjectClass;
+import org.apache.ldap.common.schema.Syntax;
+import org.apache.ldap.common.schema.MatchingRule;
+import org.apache.ldap.common.schema.AttributeType;
+import org.apache.eve.SystemPartition;
+import org.apache.eve.schema.bootstrap.*;
+
+
+/**
+ * Document me.
+ *
+ * @author <a href="mailto:directory-dev@incubator.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class GlobalRegistries implements Registries
+{
+    private GlobalAttributeTypeRegistry attributeTypeRegistry;
+    private GlobalComparatorRegistry comparatorRegistry;
+    private GlobalDitContentRuleRegistry ditContentRuleRegistry;
+    private GlobalDitStructureRuleRegistry ditStructureRuleRegistry;
+    private GlobalMatchingRuleRegistry matchingRuleRegistry;
+    private GlobalMatchingRuleUseRegistry matchingRuleUseRegistry;
+    private GlobalNameFormRegistry nameFormRegistry;
+    private GlobalNormalizerRegistry normalizerRegistry;
+    private GlobalObjectClassRegistry objectClassRegistry;
+    private GlobalOidRegistry oidRegistry;
+    private GlobalSyntaxCheckerRegistry syntaxCheckerRegistry;
+    private GlobalSyntaxRegistry syntaxRegistry;
+
+
+    public GlobalRegistries( SystemPartition systemPartition,
+                             BootstrapRegistries bootstrapRegistries )
+    {
+        oidRegistry = new GlobalOidRegistry( systemPartition,
+                ( BootstrapOidRegistry ) bootstrapRegistries.getOidRegistry() );
+        normalizerRegistry = new GlobalNormalizerRegistry( systemPartition,
+                ( BootstrapNormalizerRegistry ) bootstrapRegistries.getNormalizerRegistry());
+        comparatorRegistry = new GlobalComparatorRegistry( systemPartition,
+                ( BootstrapComparatorRegistry ) bootstrapRegistries.getComparatorRegistry());
+        syntaxCheckerRegistry = new GlobalSyntaxCheckerRegistry( systemPartition,
+                ( BootstrapSyntaxCheckerRegistry ) bootstrapRegistries.getSyntaxCheckerRegistry());
+        syntaxRegistry = new GlobalSyntaxRegistry( systemPartition,
+                ( BootstrapSyntaxRegistry ) bootstrapRegistries.getSyntaxRegistry(),
+                oidRegistry );
+        matchingRuleRegistry = new GlobalMatchingRuleRegistry( systemPartition,
+                ( BootstrapMatchingRuleRegistry ) bootstrapRegistries.getMatchingRuleRegistry(),
+                oidRegistry );
+        attributeTypeRegistry = new GlobalAttributeTypeRegistry( systemPartition,
+                ( BootstrapAttributeTypeRegistry ) bootstrapRegistries.getAttributeTypeRegistry(),
+                oidRegistry );
+        objectClassRegistry = new GlobalObjectClassRegistry( systemPartition,
+                ( BootstrapObjectClassRegistry ) bootstrapRegistries.getObjectClassRegistry(),
+                oidRegistry );
+        ditContentRuleRegistry = new GlobalDitContentRuleRegistry( systemPartition,
+                ( BootstrapDitContentRuleRegistry ) bootstrapRegistries.getDitContentRuleRegistry(),
+                oidRegistry );
+        ditStructureRuleRegistry = new GlobalDitStructureRuleRegistry( systemPartition,
+                ( BootstrapDitStructureRuleRegistry ) bootstrapRegistries.getDitStructureRuleRegistry(),
+                oidRegistry );
+        matchingRuleUseRegistry = new GlobalMatchingRuleUseRegistry( systemPartition,
+                ( BootstrapMatchingRuleUseRegistry ) bootstrapRegistries.getMatchingRuleUseRegistry(),
+                oidRegistry );
+        nameFormRegistry = new GlobalNameFormRegistry( systemPartition,
+                ( BootstrapNameFormRegistry ) bootstrapRegistries.getNameFormRegistry(),
+                oidRegistry );
+    }
+
+
+    public AttributeTypeRegistry getAttributeTypeRegistry()
+    {
+        return attributeTypeRegistry;
+    }
+
+    public ComparatorRegistry getComparatorRegistry()
+    {
+        return comparatorRegistry;
+    }
+
+    public DITContentRuleRegistry getDitContentRuleRegistry()
+    {
+        return ditContentRuleRegistry;
+    }
+
+    public DITStructureRuleRegistry getDitStructureRuleRegistry()
+    {
+        return ditStructureRuleRegistry;
+    }
+
+    public MatchingRuleRegistry getMatchingRuleRegistry()
+    {
+        return matchingRuleRegistry;
+    }
+
+    public MatchingRuleUseRegistry getMatchingRuleUseRegistry()
+    {
+        return matchingRuleUseRegistry;
+    }
+
+    public NameFormRegistry getNameFormRegistry()
+    {
+        return nameFormRegistry;
+    }
+
+    public NormalizerRegistry getNormalizerRegistry()
+    {
+        return normalizerRegistry;
+    }
+
+    public ObjectClassRegistry getObjectClassRegistry()
+    {
+        return objectClassRegistry;
+    }
+
+    public OidRegistry getOidRegistry()
+    {
+        return oidRegistry;
+    }
+
+    public SyntaxCheckerRegistry getSyntaxCheckerRegistry()
+    {
+        return syntaxCheckerRegistry;
+    }
+
+    public SyntaxRegistry getSyntaxRegistry()
+    {
+        return syntaxRegistry;
+    }
+
+
+    // ------------------------------------------------------------------------
+    // Code used to sanity check the resolution of entities in registries
+    // ------------------------------------------------------------------------
+
+
+    /**
+     * Attempts to resolve the dependent schema objects of all entities that
+     * refer to other objects within the registries.  Null references will be
+     * handed appropriately.
+     *
+     * @return a list of exceptions encountered while resolving entities
+     */
+    public List checkRefInteg()
+    {
+        ArrayList errors = new ArrayList();
+
+        Iterator list = objectClassRegistry.list();
+        while ( list.hasNext() )
+        {
+            ObjectClass oc = ( ObjectClass ) list.next();
+            resolve( oc, errors );
+        }
+
+        list = attributeTypeRegistry.list();
+        while ( list.hasNext() )
+        {
+            AttributeType at = ( AttributeType ) list.next();
+            resolve( at, errors );
+        }
+
+        list = matchingRuleRegistry.list();
+        while ( list.hasNext() )
+        {
+            MatchingRule mr = ( MatchingRule ) list.next();
+            resolve( mr, errors );
+        }
+
+        list = syntaxRegistry.list();
+        while ( list.hasNext() )
+        {
+            Syntax syntax = ( Syntax ) list.next();
+            resolve( syntax, errors );
+        }
+
+        return errors;
+    }
+
+
+    /**
+     * Attempts to resolve the SyntaxChecker associated with a Syntax.
+     *
+     * @param syntax the Syntax to resolve the SyntaxChecker of
+     * @param errors the list of errors to add exceptions to
+     * @return true if it succeeds, false otherwise
+     */
+    private boolean resolve( Syntax syntax, List errors )
+    {
+        if ( syntax == null )
+        {
+            return true;
+        }
+
+        try
+        {
+            syntax.getSyntaxChecker();
+            return true;
+        }
+        catch ( NamingException e )
+        {
+            errors.add( e );
+            return false;
+        }
+    }
+
+
+    private boolean resolve( MatchingRule mr, List errors )
+    {
+        boolean isSuccess = true;
+
+        if ( mr == null )
+        {
+            return true;
+        }
+
+        try
+        {
+            if ( mr.getComparator() == null )
+            {
+                String schema = matchingRuleRegistry.getSchemaName( mr.getOid() );
+                errors.add( new NullPointerException( "matchingRule "
+                        + mr.getName() + " in schema " + schema + " with OID "
+                        + mr.getOid() + " has a null comparator" ) );
+                isSuccess = false;
+            }
+        }
+        catch ( NamingException e )
+        {
+            errors.add( e );
+            isSuccess = false;
+        }
+
+        try
+        {
+            if ( mr.getNormalizer() == null )
+            {
+                String schema = matchingRuleRegistry.getSchemaName( mr.getOid() );
+                errors.add( new NullPointerException( "matchingRule "
+                        + mr.getName() + " in schema " + schema + " with OID "
+                        + mr.getOid() + " has a null normalizer" ) );
+                isSuccess = false;
+            }
+        }
+        catch ( NamingException e )
+        {
+            errors.add( e );
+            isSuccess = false;
+        }
+
+        try
+        {
+            isSuccess &= resolve( mr.getSyntax(), errors );
+
+            if ( mr.getSyntax() == null )
+            {
+                String schema = matchingRuleRegistry.getSchemaName( mr.getOid() );
+                errors.add( new NullPointerException( "matchingRule "
+                        + mr.getName() + " in schema " + schema + " with OID " + mr.getOid()
+                        + " has a null Syntax" ) );
+                isSuccess = false;
+            }
+        }
+        catch ( NamingException e )
+        {
+            errors.add( e );
+            isSuccess = false;
+        }
+
+        return isSuccess;
+    }
+
+
+    private boolean resolve( AttributeType at, List errors )
+    {
+        boolean isSuccess = true;
+        boolean hasMatchingRule = false;
+
+        if ( at == null )
+        {
+            return true;
+        }
+
+        try
+        {
+            isSuccess &= resolve( at.getSuperior(), errors );
+        }
+        catch ( NamingException e )
+        {
+            errors.add( e );
+            isSuccess = false;
+        }
+
+        try
+        {
+            isSuccess &= resolve( at.getEquality(), errors );
+
+            if ( at.getEquality() != null )
+            {
+                hasMatchingRule |= true;
+            }
+        }
+        catch ( NamingException e )
+        {
+            errors.add( e );
+            isSuccess = false;
+        }
+
+        try
+        {
+            isSuccess &= resolve( at.getOrdering(), errors );
+
+            if ( at.getOrdering() != null )
+            {
+                hasMatchingRule |= true;
+            }
+        }
+        catch ( NamingException e )
+        {
+            errors.add( e );
+            isSuccess = false;
+        }
+
+        try
+        {
+            isSuccess &= resolve( at.getSubstr(), errors );
+
+            if ( at.getSubstr() != null )
+            {
+                hasMatchingRule |= true;
+            }
+        }
+        catch ( NamingException e )
+        {
+            errors.add( e );
+            isSuccess = false;
+        }
+
+        try
+        {
+            isSuccess &= resolve( at.getSyntax(), errors );
+
+            if ( at.getSyntax() == null )
+            {
+                String schema = attributeTypeRegistry.getSchemaName( at.getOid() );
+                errors.add( new NullPointerException( "attributeType "
+                        + at.getName() + " in schema " + schema + " with OID "
+                        + at.getOid() + " has a null Syntax" ) );
+                isSuccess = false;
+            }
+        }
+        catch ( NamingException e )
+        {
+            errors.add( e );
+            isSuccess = false;
+        }
+
+        if ( hasMatchingRule )
+        {
+            // ----
+        }
+//        try
+//        {
+//            String schema = attributeTypeRegistry.getSchemaName( at.getOid() );
+//            if ( ! hasMatchingRule && at.getSyntax().isHumanReadable() )
+//            {
+//                errors.add( new NullPointerException( "attributeType "
+//                        + at.getName() + " in schema " + schema + " with OID "
+//                        + at.getOid() + " has a no matchingRules defined" ) );
+//                isSuccess = false;
+//            }
+//        }
+//        catch ( NamingException e )
+//        {
+//            errors.add( e );
+//            isSuccess = false;
+//        }
+
+        return isSuccess;
+    }
+
+
+    private boolean resolve( ObjectClass oc, List errors )
+    {
+        boolean isSuccess = true;
+
+        if ( oc == null )
+        {
+            return true;
+        }
+
+        ObjectClass[] superiors = new ObjectClass[0];
+        try
+        {
+            superiors = oc.getSuperClasses();
+        }
+        catch ( NamingException e )
+        {
+            superiors = new ObjectClass[0];
+            isSuccess = false;
+            errors.add( e );
+        }
+
+        for ( int ii = 0; ii < superiors.length; ii++ )
+        {
+            isSuccess &= resolve( superiors[ii], errors ) ;
+        }
+
+        AttributeType[] mayList = new AttributeType[0];
+        try
+        {
+            mayList = oc.getMayList();
+        }
+        catch ( NamingException e )
+        {
+            mayList = new AttributeType[0];
+            isSuccess = false;
+            errors.add( e );
+        }
+
+        for ( int ii = 0; ii < mayList.length; ii++ )
+        {
+            isSuccess &= resolve( mayList[ii], errors ) ;
+        }
+
+
+        AttributeType[] mustList = new AttributeType[0];
+        try
+        {
+            mustList = oc.getMustList();
+        }
+        catch ( NamingException e )
+        {
+            mustList = new AttributeType[0];
+            isSuccess = false;
+            errors.add( e );
+        }
+
+        for ( int ii = 0; ii < mustList.length; ii++ )
+        {
+            isSuccess &= resolve( mustList[ii], errors ) ;
+        }
+
+        return isSuccess;
+    }
+}

Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalSyntaxRegistry.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalSyntaxRegistry.java
(original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/GlobalSyntaxRegistry.java
Thu Oct 28 01:06:12 2004
@@ -19,9 +19,11 @@
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Iterator;
 import javax.naming.NamingException;
 
 import org.apache.ldap.common.schema.Syntax;
+import org.apache.ldap.common.util.JoinIterator;
 
 import org.apache.eve.SystemPartition;
 import org.apache.eve.schema.bootstrap.BootstrapSyntaxRegistry;
@@ -173,5 +175,12 @@
 
         throw new NamingException( "OID " + id + " not found in oid to " +
             "schema name map!" );
+    }
+
+
+    public Iterator list()
+    {
+        return new JoinIterator( new Iterator[]
+            { byOid.values().iterator(),bootstrap.list() } );
     }
 }

Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapMatchingRuleRegistry.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapMatchingRuleRegistry.java
(original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapMatchingRuleRegistry.java
Thu Oct 28 01:06:12 2004
@@ -179,7 +179,7 @@
     }
 
 
-    Iterator list()
+    public Iterator list()
     {
         return byOid.values().iterator();
     }

Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapObjectClassRegistry.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapObjectClassRegistry.java
(original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapObjectClassRegistry.java
Thu Oct 28 01:06:12 2004
@@ -151,7 +151,7 @@
      *
      * @return an iteration over the set of ObjectClasses within this registry.
      */
-    Iterator list()
+    public Iterator list()
     {
         return byOid.values().iterator();
     }

Modified: incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapSyntaxRegistry.java
==============================================================================
--- incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapSyntaxRegistry.java
(original)
+++ incubator/directory/eve/trunk/backend/core/src/java/org/apache/eve/schema/bootstrap/BootstrapSyntaxRegistry.java
Thu Oct 28 01:06:12 2004
@@ -172,7 +172,7 @@
     }
 
 
-    Iterator list()
+    public Iterator list()
     {
         return byOid.values().iterator();
     }

Mime
View raw message