directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r491353 - in /directory/branches/trunks/schema/apacheds: core/src/main/java/org/apache/directory/server/core/schema/ schema-registries/src/main/java/org/apache/directory/server/schema/registries/
Date Sun, 31 Dec 2006 00:18:30 GMT
Author: akarasulu
Date: Sat Dec 30 16:18:30 2006
New Revision: 491353

URL: http://svn.apache.org/viewvc?view=rev&rev=491353
Log:
moving data access operations to a schema partition dao

Added:
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
Modified:
    directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
    directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AbstractSchemaLoader.java

Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java?view=diff&rev=491353&r1=491352&r2=491353
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
(original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
Sat Dec 30 16:18:30 2006
@@ -33,7 +33,6 @@
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attributes;
-import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
 
 import org.apache.directory.server.core.partition.Partition;
@@ -48,12 +47,9 @@
 import org.apache.directory.server.schema.registries.NameFormRegistry;
 import org.apache.directory.server.schema.registries.NormalizerRegistry;
 import org.apache.directory.server.schema.registries.ObjectClassRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.schema.registries.SyntaxCheckerRegistry;
 import org.apache.directory.server.schema.registries.SyntaxRegistry;
-import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.filter.SimpleNode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.Normalizer;
@@ -61,6 +57,7 @@
 import org.apache.directory.shared.ldap.schema.Syntax;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+    
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -76,9 +73,9 @@
     /** static class logger */
     private final static Logger log = LoggerFactory.getLogger( PartitionSchemaLoader.class
);
     
+    private final SchemaPartitionDao dao;
     private SchemaEntityFactory factory;
     private Partition partition;
-    private OidRegistry oidRegistry;
     private AttributeTypeRegistry attrRegistry;
 
     
@@ -86,8 +83,9 @@
     {
         this.factory = new SchemaEntityFactory( bootstrapRegiistries );
         this.partition = partition;
-        this.oidRegistry = bootstrapRegiistries.getOidRegistry();
         this.attrRegistry = bootstrapRegiistries.getAttributeTypeRegistry();
+        
+        dao = new SchemaPartitionDao( this.partition, bootstrapRegiistries );
     }
     
     
@@ -117,54 +115,23 @@
 
         loadWithDependencies( enabledSchemaSet, registries );
     }
-    
+
     
     public Map<String,Schema> getSchemas() throws NamingException
     {
-        Map<String,Schema> schemas = new HashMap<String,Schema>();
-        NamingEnumeration list = listSchemas();
-        while( list.hasMore() )
-        {
-            SearchResult sr = ( SearchResult ) list.next();
-            Schema schema = factory.getSchema( sr.getAttributes() ); 
-            schemas.put( schema.getSchemaName(), schema );
-        }
-        
-        return schemas;
+        return dao.getSchemas();
     }
 
     
     public Set<String> getSchemaNames() throws NamingException
     {
-        Set<String> schemaNames = new HashSet<String>();
-        NamingEnumeration list = listSchemas();
-        while( list.hasMore() )
-        {
-            SearchResult sr = ( SearchResult ) list.next();
-            schemaNames.add( ( String ) sr.getAttributes().get( "cn" ).get() );
-        }
-        
-        return schemaNames;
+        return dao.getSchemaNames();
     }
     
     
-    private NamingEnumeration listSchemas() throws NamingException
-    {
-        LdapDN base = new LdapDN( "ou=schema" );
-        base.normalize( attrRegistry.getNormalizerMapping() );
-        ExprNode filter = new SimpleNode( oidRegistry.getOid( "objectClass" ), "metaSchema",
SimpleNode.EQUALITY );
-        SearchControls searchControls = new SearchControls();
-        searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-        
-        return partition.search( base, new HashMap(), filter, searchControls );
-    }
-
-
     public Schema getSchema( String schemaName ) throws NamingException
     {
-        LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
-        dn.normalize( attrRegistry.getNormalizerMapping() );
-        return factory.getSchema( partition.lookup( dn ) );
+        return dao.getSchema( schemaName );
     }
 
 

Added: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java?view=auto&rev=491353
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
(added)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
Sat Dec 30 16:18:30 2006
@@ -0,0 +1,142 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.directory.server.core.schema;
+
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
+import javax.naming.directory.SearchResult;
+
+import org.apache.directory.server.core.partition.Partition;
+import org.apache.directory.server.schema.bootstrap.Schema;
+import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
+import org.apache.directory.server.schema.registries.OidRegistry;
+import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.SimpleNode;
+import org.apache.directory.shared.ldap.name.LdapDN;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A specialized data access object for managing schema objects in the
+ * schema partition.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SchemaPartitionDao
+{
+    /** static class logger */
+    private final static Logger log = LoggerFactory.getLogger( SchemaPartitionDao.class );
+
+    private final Partition partition;
+    private final Registries bootstrapRegistries;
+    private final SchemaEntityFactory factory;
+    private final OidRegistry oidRegistry;
+    private final AttributeTypeRegistry attrRegistry;
+    
+    
+    /**
+     * Creates a schema dao object backing information within a schema partition.
+     * 
+     * @param partition
+     * @throws NamingException 
+     */
+    public SchemaPartitionDao( Partition partition, Registries bootstrapRegistries ) throws
NamingException
+    {
+        this.partition = partition;
+        this.bootstrapRegistries = bootstrapRegistries;
+        this.factory = new SchemaEntityFactory( this.bootstrapRegistries );
+        this.oidRegistry = this.bootstrapRegistries.getOidRegistry();
+        this.attrRegistry = this.bootstrapRegistries.getAttributeTypeRegistry();
+    }
+    
+    
+    public Map<String,Schema> getSchemas() throws NamingException
+    {
+        Map<String,Schema> schemas = new HashMap<String,Schema>();
+        NamingEnumeration list = listSchemas();
+        while( list.hasMore() )
+        {
+            SearchResult sr = ( SearchResult ) list.next();
+            Schema schema = factory.getSchema( sr.getAttributes() ); 
+            schemas.put( schema.getSchemaName(), schema );
+        }
+        
+        return schemas;
+    }
+
+    
+    public Set<String> getSchemaNames() throws NamingException
+    {
+        Set<String> schemaNames = new HashSet<String>();
+        NamingEnumeration list = listSchemas();
+        while( list.hasMore() )
+        {
+            SearchResult sr = ( SearchResult ) list.next();
+            schemaNames.add( ( String ) sr.getAttributes().get( "cn" ).get() );
+        }
+        
+        return schemaNames;
+    }
+    
+    
+    private NamingEnumeration listSchemas() throws NamingException
+    {
+        LdapDN base = new LdapDN( "ou=schema" );
+        base.normalize( attrRegistry.getNormalizerMapping() );
+        ExprNode filter = new SimpleNode( oidRegistry.getOid( "objectClass" ), "metaSchema",
SimpleNode.EQUALITY );
+        SearchControls searchControls = new SearchControls();
+        searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
+        
+        return partition.search( base, new HashMap(), filter, searchControls );
+    }
+
+
+    public Schema getSchema( String schemaName ) throws NamingException
+    {
+        LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
+        dn.normalize( attrRegistry.getNormalizerMapping() );
+        return factory.getSchema( partition.lookup( dn ) );
+    }
+
+
+    public Schema getSchema( String schemaName, Properties schemaProperties ) throws NamingException
+    {
+        return getSchema( schemaName );
+    }
+    
+    
+    public String getSchemaNameForAttribute( String attributeName ) throws NamingException
+    {
+        throw new NotImplementedException();
+    }
+}

Modified: directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AbstractSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AbstractSchemaLoader.java?view=diff&rev=491353&r1=491352&r2=491353
==============================================================================
--- directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AbstractSchemaLoader.java
(original)
+++ directory/branches/trunks/schema/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AbstractSchemaLoader.java
Sat Dec 30 16:18:30 2006
@@ -19,6 +19,7 @@
  */
 package org.apache.directory.server.schema.registries;
 
+
 import java.util.Map;
 import java.util.Properties;
 import java.util.Stack;
@@ -30,7 +31,6 @@
 import org.slf4j.LoggerFactory;
 
 
-
 /**
  * An abstract class with a utility method and setListener() implemented.
  *
@@ -87,6 +87,7 @@
     {
         if ( registries.getLoadedSchemas().containsKey( schema.getSchemaName() ) )
         {
+            log.warn( "{} schema has already been loaded" + schema.getSchemaName() );
             return;
         }
         



Mime
View raw message