You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2006/12/12 06:31:17 UTC
svn commit: r486036 - in /directory/branches/trunks/schema/apacheds:
bootstrap-partition/
bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/
core/src/main/java/org/apache/directory/server/core/schema/
core/src/main/java/o...
Author: akarasulu
Date: Mon Dec 11 21:31:13 2006
New Revision: 486036
URL: http://svn.apache.org/viewvc?view=rev&rev=486036
Log:
adding more functionality to the bootstrap partition plugin that pre-loads schema into the schema partition
Added:
directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributeClassLoader.java
directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java
directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/SchemaEntityFactory.java
Modified:
directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml
directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SyntaxCheckerRegistry.java
directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapSyntaxCheckerRegistry.java
directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema
Modified: directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml?view=diff&rev=486036&r1=486035&r2=486036
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml (original)
+++ directory/branches/trunks/schema/apacheds/bootstrap-partition/pom.xml Mon Dec 11 21:31:13 2006
@@ -38,6 +38,11 @@
<groupId>org.apache.directory.server</groupId>
<artifactId>apacheds-bootstrap-plugin</artifactId>
<configuration>
+ <indexedAttributes>
+ <indexedAttribute>ou</indexedAttribute>
+ <indexedAttribute>cn</indexedAttribute>
+ <indexedAttribute>m-oid</indexedAttribute>
+ </indexedAttributes>
<bootstrapSchemaClasses>
<bootstrapSchemaClass>org.apache.directory.server.core.schema.bootstrap.ApachednsSchema</bootstrapSchemaClass>
<bootstrapSchemaClass>org.apache.directory.server.core.schema.bootstrap.AutofsSchema</bootstrapSchemaClass>
Added: directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributeClassLoader.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributeClassLoader.java?view=auto&rev=486036
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributeClassLoader.java (added)
+++ directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributeClassLoader.java Mon Dec 11 21:31:13 2006
@@ -0,0 +1,67 @@
+/*
+ * 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.bootstrap.plugin;
+
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+
+
+/**
+ * A class loader that loads classes from an attribute within an entry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$ $Date$
+ */
+public class AttributeClassLoader extends ClassLoader
+{
+ public Attribute attribute;
+
+
+ public AttributeClassLoader()
+ {
+ super( AttributeClassLoader.class.getClassLoader() );
+ }
+
+
+ public void setAttribute( Attribute attribute )
+ {
+ this.attribute = attribute;
+ }
+
+
+ public Class findClass( String name ) throws ClassNotFoundException
+ {
+ byte[] classBytes = null;
+
+ try
+ {
+ classBytes = ( byte[] ) attribute.get();
+ }
+ catch ( NamingException e )
+ {
+ throw new ClassNotFoundException( "Failed to access attribute bytes.", e );
+ }
+
+ return defineClass( name, classBytes, 0, classBytes.length );
+ }
+}
Added: directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java?view=auto&rev=486036
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java (added)
+++ directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/AttributesFactory.java Mon Dec 11 21:31:13 2006
@@ -0,0 +1,137 @@
+/*
+ * 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.bootstrap.plugin;
+
+
+import java.util.Comparator;
+
+import javax.naming.directory.Attributes;
+import javax.naming.directory.BasicAttributes;
+
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.DITContentRule;
+import org.apache.directory.shared.ldap.schema.DITStructureRule;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.MatchingRuleUse;
+import org.apache.directory.shared.ldap.schema.NameForm;
+import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.shared.ldap.schema.Syntax;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+
+
+/**
+ * A factory that generates an entry using the meta schema for schema
+ * elements.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class AttributesFactory
+{
+ public Attributes getAttributes( SyntaxChecker syntaxChecker )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "metaSyntaxChecker" );
+ entry.put( "m-oid", syntaxChecker.getSyntaxOid() );
+ entry.put( "m-fqcn", syntaxChecker.getClass().getName() );
+ return entry;
+ }
+
+
+ public Attributes getAttributes( Syntax syntax )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "" );
+ return entry;
+ }
+
+
+ public Attributes getAttributes( Normalizer normalizer )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "" );
+ return entry;
+ }
+
+
+ public Attributes getAttributes( Comparator<Object> comparator )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "" );
+ return entry;
+ }
+
+
+ public Attributes getAttributes( MatchingRule matchingRule )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "" );
+ return entry;
+ }
+
+
+ public Attributes getAttributes( MatchingRuleUse matchingRuleUse )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "" );
+ return entry;
+ }
+
+
+ public Attributes getAttributes( DITStructureRule dITStructureRule )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "" );
+ return entry;
+ }
+
+
+ public Attributes getAttributes( DITContentRule dITContentRule )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "" );
+ return entry;
+ }
+
+
+ public Attributes getAttributes( NameForm nameForm )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "" );
+ return entry;
+ }
+
+
+ public Attributes getAttributes( AttributeType attributeType )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "" );
+ return entry;
+ }
+
+
+ public Attributes getAttributes( ObjectClass objectClass )
+ {
+ BasicAttributes entry = new BasicAttributes( "objectClass", "top", true );
+ entry.get( "objectClass" ).add( "" );
+ return entry;
+ }
+}
Modified: directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java?view=diff&rev=486036&r1=486035&r2=486036
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java (original)
+++ directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/BootstrapPlugin.java Mon Dec 11 21:31:13 2006
@@ -21,15 +21,18 @@
import java.io.File;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttributes;
import org.apache.directory.server.core.configuration.MutablePartitionConfiguration;
import org.apache.directory.server.core.configuration.MutableStartupConfiguration;
import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition;
import org.apache.directory.server.core.schema.Registries;
+import org.apache.directory.server.core.schema.SyntaxCheckerRegistry;
import org.apache.directory.server.core.schema.bootstrap.ApacheSchema;
import org.apache.directory.server.core.schema.bootstrap.ApachemetaSchema;
import org.apache.directory.server.core.schema.bootstrap.BootstrapRegistries;
@@ -37,6 +40,9 @@
import org.apache.directory.server.core.schema.bootstrap.BootstrapSchemaLoader;
import org.apache.directory.server.core.schema.bootstrap.CoreSchema;
import org.apache.directory.server.core.schema.bootstrap.SystemSchema;
+import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -66,7 +72,15 @@
* @parameter
*/
private String[] bootstrapSchemaClasses;
-
+
+ /**
+ * Attributes to index.
+ *
+ * @parameter
+ */
+ private String[] indexedAttributes;
+
+ private AttributesFactory attributesFactory = new AttributesFactory();
/**
* Loads a bunch of bootstrap classes into memory then adds them to a new
@@ -87,6 +101,7 @@
schemas.add( new ApachemetaSchema() );
schemas.add( new CoreSchema() );
+ getLog().info( "------------------------------------------------------" );
getLog().info( "Found bootstrap schemas: " );
// start loading other schemas from the plugin's configuration section
@@ -116,6 +131,7 @@
getLog().info( "\t" + schemaClassName );
}
+ getLog().info( "------------------------------------------------------" );
BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
try
@@ -130,7 +146,6 @@
// start up the schema partition
JdbmPartition partition = new JdbmPartition();
-
MutableStartupConfiguration msConf = new MutableStartupConfiguration();
msConf.setWorkingDirectory( outputDirectory );
@@ -141,11 +156,14 @@
rootEntry.put( "ou", "schema" );
mpConfig.setContextEntry( rootEntry );
- Set<String> indexedAttributes = new HashSet<String>();
- indexedAttributes.add( "ou" );
- indexedAttributes.add( "cn" );
- indexedAttributes.add( "m-oid" );
- mpConfig.setIndexedAttributes( indexedAttributes );
+ // add the indices
+ Set<String> indexSet = new HashSet<String>();
+ for ( String index:indexedAttributes )
+ {
+ indexSet.add( index );
+ }
+
+ mpConfig.setIndexedAttributes( indexSet );
try
{
@@ -154,6 +172,7 @@
catch ( NamingException e1 )
{
e1.printStackTrace();
+ throw new MojoFailureException( "Failed to setup parition configuration: " + e1.getMessage() );
}
mpConfig.setName( "schema" );
@@ -165,6 +184,74 @@
catch ( NamingException e )
{
e.printStackTrace();
+ throw new MojoFailureException( "Failed to initialize parition: " + e.getMessage() );
}
+
+ try
+ {
+ Attributes entry = new LockableAttributesImpl();
+ entry.put( "objectClass", "top" );
+ entry.get( "objectClass" ).add( "organizationalUnit" );
+ entry.put( "ou", "schema" );
+ partition.add( new LdapDN( "ou=schema" ), entry );
+
+ addSyntaxCheckers( registries.getSyntaxCheckerRegistry(), partition );
+ }
+ catch ( NamingException e )
+ {
+ e.printStackTrace();
+ throw new MojoFailureException( "Failed to add syntaxCheckers to partition: " + e.getMessage() );
+ }
+ }
+
+
+ private void addSyntaxCheckers( SyntaxCheckerRegistry syntaxCheckerRegistry, JdbmPartition partition ) throws NamingException
+ {
+ Iterator<SyntaxChecker> ii = syntaxCheckerRegistry.iterator();
+ while ( ii.hasNext() )
+ {
+ SyntaxChecker syntaxChecker = ii.next();
+ getLog().info( "Adding syntax checker with oid = " + syntaxChecker.getSyntaxOid() );
+ String schemaName = syntaxCheckerRegistry.getSchemaName( syntaxChecker.getSyntaxOid() );
+ LdapDN dn = checkCreateSchema( schemaName, partition );
+ dn.add( "ou=syntaxCheckers" );
+ checkCreateContainer( dn, partition );
+ Attributes entry = attributesFactory.getAttributes( syntaxChecker );
+ dn.add( "m-oid=" + syntaxChecker.getSyntaxOid() );
+ partition.add( dn, entry );
+ }
+ }
+
+
+ private void checkCreateContainer( LdapDN dn, JdbmPartition partition ) throws NamingException
+ {
+ if ( partition.hasEntry( dn ) )
+ {
+ return;
+ }
+
+ Attributes entry = new LockableAttributesImpl();
+ entry.put( "objectClass", "top" );
+ entry.get( "objectClass" ).add( "organizationalUnit" );
+ entry.put( "ou", dn.getRdn().getValue() );
+ partition.add( dn, entry );
+ }
+
+
+ private LdapDN checkCreateSchema( String schemaName, JdbmPartition partition ) throws NamingException
+ {
+ LdapDN dn = new LdapDN( "cn=" + schemaName + ",ou=schema" );
+ if ( partition.hasEntry( dn ) )
+ {
+ return dn;
+ }
+
+ Attributes entry = new LockableAttributesImpl();
+ entry.put( "objectClass", "top" );
+ entry.get( "objectClass" ).add( "metaTop" );
+ entry.get( "objectClass" ).add( "metaSchema" );
+ entry.put( "cn", schemaName );
+ partition.add( dn, entry );
+ return dn;
}
}
Added: directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/SchemaEntityFactory.java?view=auto&rev=486036
==============================================================================
--- directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/SchemaEntityFactory.java (added)
+++ directory/branches/trunks/schema/apacheds/bootstrap-plugin/src/main/java/org/apache/directory/server/core/bootstrap/plugin/SchemaEntityFactory.java Mon Dec 11 21:31:13 2006
@@ -0,0 +1,203 @@
+/*
+ * 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.bootstrap.plugin;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+
+import org.apache.directory.server.core.schema.Registries;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+
+
+/**
+ * Showing how it's done ...
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class SchemaEntityFactory
+{
+ /** Used for looking up the setRegistries(Registries) method */
+ private final static Class[] parameterTypes = new Class[] { Registries.class };
+
+ /** Used for dependency injection of Registries via setter into schema objects */
+ private final Registries registries;
+ /** A special ClassLoader that loads a class from the bytecode attribute */
+ private final AttributeClassLoader classLoader;
+
+
+ public SchemaEntityFactory( Registries registries )
+ {
+ this.registries = registries;
+ this.classLoader = new AttributeClassLoader();
+ }
+
+
+ /**
+ * Example of how to retrieve and load a syntaxChecker class from the DIT.
+ *
+ * @param entry the entry to load the syntaxChecker from
+ * @return the loaded SyntaxChecker
+ * @throws NamingException if anything fails during loading
+ */
+ public SyntaxChecker getSyntaxChecker( Attributes entry ) throws NamingException
+ {
+ if ( entry == null )
+ {
+ throw new NullPointerException( "entry cannot be null" );
+ }
+
+ if ( entry.get( "m-fqcn" ) == null )
+ {
+ throw new NullPointerException( "entry must have a valid m-fqcn attribute" );
+ }
+
+ String className = ( String ) entry.get( "m-fqcn" ).get();
+ SyntaxChecker syntaxChecker = null;
+ Class clazz = null;
+
+ if ( entry.get( "m-bytecode" ) == null )
+ {
+ try
+ {
+ clazz = Class.forName( className );
+ }
+ catch ( ClassNotFoundException e )
+ {
+ NamingException ne = new NamingException( "SyntaxChecker class "+ className + " was not found" );
+ ne.setRootCause( e );
+ throw ne;
+ }
+ }
+ else
+ {
+ try
+ {
+ clazz = classLoader.loadClass( className );
+ }
+ catch ( ClassCastException e )
+ {
+ NamingException ne = new NamingException( "Class "+ className + " does not implement SyntaxChecker" );
+ ne.setRootCause( e );
+ throw ne;
+ }
+ catch ( ClassNotFoundException e )
+ {
+ NamingException ne = new NamingException( "SyntaxChecker class "+ className + " was not found" );
+ ne.setRootCause( e );
+ throw ne;
+ }
+ }
+
+
+ try
+ {
+ syntaxChecker = ( SyntaxChecker ) clazz.newInstance();
+ }
+ catch ( ClassCastException e )
+ {
+ NamingException ne = new NamingException( "Class "+ className + " does not implement SyntaxChecker" );
+ ne.setRootCause( e );
+ throw ne;
+ }
+ catch ( InstantiationException e )
+ {
+ NamingException ne = new NamingException( "Failed to instantiate syntaxChecker class "+ className
+ + ".\nCheck that a default constructor exists for the class." );
+ ne.setRootCause( e );
+ throw ne;
+ }
+ catch ( IllegalAccessException e )
+ {
+ NamingException ne = new NamingException( "Failed to instantiate syntaxChecker class "+ className
+ + ".\nCheck that a **PUBLIC** accessible default constructor exists for the class." );
+ ne.setRootCause( e );
+ throw ne;
+ }
+
+ // try now before returning to check if we can inject a Registries object
+ injectRegistries( syntaxChecker );
+ return syntaxChecker;
+ }
+
+
+ /**
+ * Uses reflection to see if a setRegistries( Registries ) method exists on the
+ * object's class. If so then the registries are dependency injected into the
+ * new schema object.
+ *
+ * @param obj a schema object to have a Registries dependency injected.
+ */
+ private void injectRegistries( Object obj ) throws NamingException
+ {
+ String className = obj.getClass().getName();
+
+ try
+ {
+ Method method = obj.getClass().getMethod( "setRegistries", parameterTypes );
+
+ if ( method == null )
+ {
+ return;
+ }
+
+ Object[] args = new Object[] { this.registries };
+ method.invoke( obj, args );
+ }
+ catch ( SecurityException e )
+ {
+ NamingException ne = new NamingException( "SyntaxChecker class "+ className
+ + " could not have the Registries dependency injected." );
+ ne.setRootCause( e );
+ throw ne;
+ }
+ catch ( NoSuchMethodException e )
+ {
+ NamingException ne = new NamingException( "SyntaxChecker class "+ className
+ + " could not have the Registries dependency injected." );
+ ne.setRootCause( e );
+ throw ne;
+ }
+ catch ( IllegalArgumentException e )
+ {
+ NamingException ne = new NamingException( "SyntaxChecker class "+ className
+ + " could not have the Registries dependency injected." );
+ ne.setRootCause( e );
+ throw ne;
+ }
+ catch ( IllegalAccessException e )
+ {
+ NamingException ne = new NamingException( "SyntaxChecker class "+ className
+ + " could not have the Registries dependency injected." );
+ ne.setRootCause( e );
+ throw ne;
+ }
+ catch ( InvocationTargetException e )
+ {
+ NamingException ne = new NamingException( "SyntaxChecker class "+ className
+ + " could not have the Registries dependency injected." );
+ ne.setRootCause( e );
+ throw ne;
+ }
+ }
+}
Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SyntaxCheckerRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SyntaxCheckerRegistry.java?view=diff&rev=486036&r1=486035&r2=486036
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SyntaxCheckerRegistry.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SyntaxCheckerRegistry.java Mon Dec 11 21:31:13 2006
@@ -20,6 +20,8 @@
package org.apache.directory.server.core.schema;
+import java.util.Iterator;
+
import javax.naming.NamingException;
import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
@@ -74,4 +76,11 @@
* otherwise
*/
boolean hasSyntaxChecker( String oid );
+
+ /**
+ * Get's an iterator over all the syntaxCheckers associated with this registry.
+ *
+ * @return an Iterator over all the syntaxCheckers
+ */
+ Iterator<SyntaxChecker> iterator();
}
Modified: directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapSyntaxCheckerRegistry.java
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapSyntaxCheckerRegistry.java?view=diff&rev=486036&r1=486035&r2=486036
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapSyntaxCheckerRegistry.java (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/java/org/apache/directory/server/core/schema/bootstrap/BootstrapSyntaxCheckerRegistry.java Mon Dec 11 21:31:13 2006
@@ -21,6 +21,7 @@
import java.util.HashMap;
+import java.util.Iterator;
import java.util.Map;
import javax.naming.NamingException;
@@ -42,9 +43,9 @@
/** static class logger */
private final static Logger log = LoggerFactory.getLogger( BootstrapSyntaxCheckerRegistry.class );
/** a map by OID of SyntaxCheckers */
- private final Map byOid;
+ private final Map<String, SyntaxChecker> byOid;
/** maps an OID to a schema name*/
- private final Map oidToSchema;
+ private final Map<String, String> oidToSchema;
// ------------------------------------------------------------------------
@@ -56,8 +57,8 @@
*/
public BootstrapSyntaxCheckerRegistry()
{
- this.byOid = new HashMap();
- this.oidToSchema = new HashMap();
+ this.byOid = new HashMap<String, SyntaxChecker>();
+ this.oidToSchema = new HashMap<String, String>();
}
@@ -108,7 +109,7 @@
public String getSchemaName( String oid ) throws NamingException
{
- if ( Character.isDigit( oid.charAt( 0 ) ) )
+ if ( ! Character.isDigit( oid.charAt( 0 ) ) )
{
throw new NamingException( "Looks like the arg is not a numeric OID" );
}
@@ -119,5 +120,11 @@
}
throw new NamingException( "OID " + oid + " not found in oid to " + "schema name map!" );
+ }
+
+
+ public Iterator<SyntaxChecker> iterator()
+ {
+ return byOid.values().iterator();
}
}
Modified: directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema
URL: http://svn.apache.org/viewvc/directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema?view=diff&rev=486036&r1=486035&r2=486036
==============================================================================
--- directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema (original)
+++ directory/branches/trunks/schema/apacheds/core/src/main/schema/apachemeta.schema Mon Dec 11 21:31:13 2006
@@ -20,75 +20,79 @@
# MetaMeta Schema
# =============================================================================
#
-# +------------------------------+-----------------------------+
-# | Syntax OID | name |
-# +------------------------------+-----------------------------+
-# | 1.3.6.1.4.1.18060.0.4.0.0.1 | objectClassType |
-# | 1.3.6.1.4.1.18060.0.4.0.0.2 | NumericOid |
-# | 1.3.6.1.4.1.18060.0.4.0.0.3 | attributeTypeUsage |
-# | 1.3.6.1.4.1.18060.0.4.0.0.4 | number |
-# | 1.3.6.1.4.1.18060.0.4.0.0.5 | oidLen |
-# +------------------------------+-----------------------------+
+# +------------------------------+-----------------------------+
+# | Syntax OID | name |
+# +------------------------------+-----------------------------+
+# | 1.3.6.1.4.1.18060.0.4.0.0.1 | objectClassType |
+# | 1.3.6.1.4.1.18060.0.4.0.0.2 | NumericOid |
+# | 1.3.6.1.4.1.18060.0.4.0.0.3 | attributeTypeUsage |
+# | 1.3.6.1.4.1.18060.0.4.0.0.4 | number |
+# | 1.3.6.1.4.1.18060.0.4.0.0.5 | oidLen |
+# +------------------------------+-----------------------------+
#
-# +------------------------------+-----------------------------+
-# | MatchingRule OID | name |
-# +------------------------------+-----------------------------+
-# | 1.3.6.1.4.1.18060.0.4.0.1.0 | nameOrNumericIdMatch |
-# | 1.3.6.1.4.1.18060.0.4.0.1.1 | objectClassTypeMatch |
-# | 1.3.6.1.4.1.18060.0.4.0.1.2 | numericOidMatch |
-# | 1.3.6.1.4.1.18060.0.4.0.1.3 | supDITStructureRuleMatch |
-# | 1.3.6.1.4.1.18060.0.4.0.1.4 | ruleIDMatch |
-# +------------------------------+-----------------------------+
+# +------------------------------+-----------------------------+
+# | MatchingRule OID | name |
+# +------------------------------+-----------------------------+
+# | 1.3.6.1.4.1.18060.0.4.0.1.0 | nameOrNumericIdMatch |
+# | 1.3.6.1.4.1.18060.0.4.0.1.1 | objectClassTypeMatch |
+# | 1.3.6.1.4.1.18060.0.4.0.1.2 | numericOidMatch |
+# | 1.3.6.1.4.1.18060.0.4.0.1.3 | supDITStructureRuleMatch |
+# | 1.3.6.1.4.1.18060.0.4.0.1.4 | ruleIDMatch |
+# +------------------------------+-----------------------------+
#
-# +------------------------------+-----------------------------+
-# | AttributeType OID | name |
-# +------------------------------+-----------------------------+
-# | 1.3.6.1.4.1.18060.0.4.0.2.1 | m-oid |
-# | 1.3.6.1.4.1.18060.0.4.0.2.2 | m-name |
-# | 1.3.6.1.4.1.18060.0.4.0.2.3 | m-description |
-# | 1.3.6.1.4.1.18060.0.4.0.2.4 | m-obsolete |
-# | 1.3.6.1.4.1.18060.0.4.0.2.5 | m-supObjectclass |
-# | 1.3.6.1.4.1.18060.0.4.0.2.6 | m-must |
-# | 1.3.6.1.4.1.18060.0.4.0.2.7 | m-may |
-# | 1.3.6.1.4.1.18060.0.4.0.2.8 | m-typeObjectClass |
-# | 1.3.6.1.4.1.18060.0.4.0.2.9 | m-extensionObjectClass |
-# | 1.3.6.1.4.1.18060.0.4.0.2.10 | m-supAttributeType |
-# | 1.3.6.1.4.1.18060.0.4.0.2.11 | m-equality |
-# | 1.3.6.1.4.1.18060.0.4.0.2.12 | m-ordering |
-# | 1.3.6.1.4.1.18060.0.4.0.2.13 | m-substr |
-# | 1.3.6.1.4.1.18060.0.4.0.2.14 | m-syntax |
-# | 1.3.6.1.4.1.18060.0.4.0.2.15 | m-singleValue |
-# | 1.3.6.1.4.1.18060.0.4.0.2.16 | m-collective |
-# | 1.3.6.1.4.1.18060.0.4.0.2.17 | m-noUserModification |
-# | 1.3.6.1.4.1.18060.0.4.0.2.18 | m-usage |
-# | 1.3.6.1.4.1.18060.0.4.0.2.19 | m-extensionAttributeType |
-# | 1.3.6.1.4.1.18060.0.4.0.2.20 | m-ruleId |
-# | 1.3.6.1.4.1.18060.0.4.0.2.21 | m-form |
-# | 1.3.6.1.4.1.18060.0.4.0.2.22 | m-supDITStructureRule |
-# | 1.3.6.1.4.1.18060.0.4.0.2.23 | m-extensionDITStructureRule |
-# | 1.3.6.1.4.1.18060.0.4.0.2.24 | m-oc |
-# | 1.3.6.1.4.1.18060.0.4.0.2.25 | m-extensionNameForm |
-# | 1.3.6.1.4.1.18060.0.4.0.2.26 | m-aux |
-# | 1.3.6.1.4.1.18060.0.4.0.2.27 | m-not |
-# | 1.3.6.1.4.1.18060.0.4.0.2.28 | m-extensionDITContentRule |
-# | 1.3.6.1.4.1.18060.0.4.0.2.29 | m-applies |
-# | 1.3.6.1.4.1.18060.0.4.0.2.30 | m-extensionMatchingRuleUse |
-# | 1.3.6.1.4.1.18060.0.4.0.2.31 | m-matchingRuleSyntax |
-# +------------------------------+-----------------------------+
+# +------------------------------+-----------------------------+
+# | AttributeType OID | name |
+# +------------------------------+-----------------------------+
+# | 1.3.6.1.4.1.18060.0.4.0.2.1 | m-oid |
+# | 1.3.6.1.4.1.18060.0.4.0.2.2 | m-name |
+# | 1.3.6.1.4.1.18060.0.4.0.2.3 | m-description |
+# | 1.3.6.1.4.1.18060.0.4.0.2.4 | m-obsolete |
+# | 1.3.6.1.4.1.18060.0.4.0.2.5 | m-supObjectclass |
+# | 1.3.6.1.4.1.18060.0.4.0.2.6 | m-must |
+# | 1.3.6.1.4.1.18060.0.4.0.2.7 | m-may |
+# | 1.3.6.1.4.1.18060.0.4.0.2.8 | m-typeObjectClass |
+# | 1.3.6.1.4.1.18060.0.4.0.2.9 | m-extensionObjectClass |
+# | 1.3.6.1.4.1.18060.0.4.0.2.10 | m-supAttributeType |
+# | 1.3.6.1.4.1.18060.0.4.0.2.11 | m-equality |
+# | 1.3.6.1.4.1.18060.0.4.0.2.12 | m-ordering |
+# | 1.3.6.1.4.1.18060.0.4.0.2.13 | m-substr |
+# | 1.3.6.1.4.1.18060.0.4.0.2.14 | m-syntax |
+# | 1.3.6.1.4.1.18060.0.4.0.2.15 | m-singleValue |
+# | 1.3.6.1.4.1.18060.0.4.0.2.16 | m-collective |
+# | 1.3.6.1.4.1.18060.0.4.0.2.17 | m-noUserModification |
+# | 1.3.6.1.4.1.18060.0.4.0.2.18 | m-usage |
+# | 1.3.6.1.4.1.18060.0.4.0.2.19 | m-extensionAttributeType |
+# | 1.3.6.1.4.1.18060.0.4.0.2.20 | m-ruleId |
+# | 1.3.6.1.4.1.18060.0.4.0.2.21 | m-form |
+# | 1.3.6.1.4.1.18060.0.4.0.2.22 | m-supDITStructureRule |
+# | 1.3.6.1.4.1.18060.0.4.0.2.23 | m-extensionDITStructureRule |
+# | 1.3.6.1.4.1.18060.0.4.0.2.24 | m-oc |
+# | 1.3.6.1.4.1.18060.0.4.0.2.25 | m-extensionNameForm |
+# | 1.3.6.1.4.1.18060.0.4.0.2.26 | m-aux |
+# | 1.3.6.1.4.1.18060.0.4.0.2.27 | m-not |
+# | 1.3.6.1.4.1.18060.0.4.0.2.28 | m-extensionDITContentRule |
+# | 1.3.6.1.4.1.18060.0.4.0.2.29 | m-applies |
+# | 1.3.6.1.4.1.18060.0.4.0.2.30 | m-extensionMatchingRuleUse |
+# | 1.3.6.1.4.1.18060.0.4.0.2.31 | m-matchingRuleSyntax |
+# | 1.3.6.1.4.1.18060.0.4.0.2.32 | m-fqcn |
+# | 1.3.6.1.4.1.18060.0.4.0.2.33 | m-bytecode |
+# +------------------------------+-----------------------------+
#
-# +------------------------------+-----------------------------+
-# | Objectclasses OID | name |
-# +------------------------------+-----------------------------+
-# | 1.3.6.1.4.1.18060.0.4.0.3.1 | metaTop |
-# | 1.3.6.1.4.1.18060.0.4.0.3.2 | metaObjectclass |
-# | 1.3.6.1.4.1.18060.0.4.0.3.3 | metaAttributeType |
-# | 1.3.6.1.4.1.18060.0.4.0.3.4 | metaSyntax |
-# | 1.3.6.1.4.1.18060.0.4.0.3.5 | metaMatchingRule |
-# | 1.3.6.1.4.1.18060.0.4.0.3.6 | metaDITStructureRule |
-# | 1.3.6.1.4.1.18060.0.4.0.3.7 | metaNameForm |
-# | 1.3.6.1.4.1.18060.0.4.0.3.8 | metaMatchingRuleUse |
-# | 1.3.6.1.4.1.18060.0.4.0.3.9 | metaDITContentRule |
-# +------------------------------+-----------------------------+
+# +------------------------------+-----------------------------+
+# | Objectclasses OID | name |
+# +------------------------------+-----------------------------+
+# | 1.3.6.1.4.1.18060.0.4.0.3.1 | metaTop |
+# | 1.3.6.1.4.1.18060.0.4.0.3.2 | metaObjectclass |
+# | 1.3.6.1.4.1.18060.0.4.0.3.3 | metaAttributeType |
+# | 1.3.6.1.4.1.18060.0.4.0.3.4 | metaSyntax |
+# | 1.3.6.1.4.1.18060.0.4.0.3.5 | metaMatchingRule |
+# | 1.3.6.1.4.1.18060.0.4.0.3.6 | metaDITStructureRule |
+# | 1.3.6.1.4.1.18060.0.4.0.3.7 | metaNameForm |
+# | 1.3.6.1.4.1.18060.0.4.0.3.8 | metaMatchingRuleUse |
+# | 1.3.6.1.4.1.18060.0.4.0.3.9 | metaDITContentRule |
+# | 1.3.6.1.4.1.18060.0.4.0.3.10 | metaSyntaxChecker |
+# | 1.3.6.1.4.1.18060.0.4.0.3.11 | metaSchema |
+# +------------------------------+-----------------------------+
#
# =============================================================================
@@ -109,7 +113,7 @@
objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.2
NAME 'metaObjectclass'
DESC 'Meta definition of the objectclass object'
- SUP MetaTop
+ SUP metaTop
STRUCTURAL
MUST m-name
MAY ( m-supObjectClass $ m-must $ m-may $ m-typeObjectClass $
@@ -120,7 +124,7 @@
objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.3
NAME 'metaAttributeType'
DESC 'Meta definition of the AttributeType object'
- SUP MetaTop
+ SUP metaTop
STRUCTURAL
MUST ( m-name $ m-syntax )
MAY ( m-supAttributeType $ m-obsolete $
@@ -132,7 +136,7 @@
objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.4
NAME 'metaSyntax'
DESC 'Meta definition of the Syntax object'
- SUP MetaTop
+ SUP metaTop
STRUCTURAL
)
@@ -140,7 +144,7 @@
objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.5
NAME 'metaMatchingRule'
DESC 'Meta definition of the MatchingRule object'
- SUP MetaTop
+ SUP metaTop
STRUCTURAL
MUST m-syntax
MAY ( m-obsolete $ m-extensionAttributeType )
@@ -160,7 +164,7 @@
objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.7
NAME 'metaNameForm'
DESC 'Meta definition of the NameForm object'
- SUP MetaTop
+ SUP metaTop
STRUCTURAL
MUST ( m-oc $ m-must )
MAY ( m-obsolete $ m-may $ m-extensionNameForm )
@@ -170,7 +174,7 @@
objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.8
NAME 'metaMatchingRuleUse'
DESC 'Meta definition of the MatchingRuleUse object'
- SUP MetaTop
+ SUP metaTop
STRUCTURAL
MUST m-applies
MAY ( m-obsolete $ m-extensionMatchingRuleUse )
@@ -180,11 +184,30 @@
objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.9
NAME 'metaDITContentRule'
DESC 'Meta definition of the DITContentRule object'
- SUP MetaTop
+ SUP metaTop
STRUCTURAL
MAY ( m-obsolete $ m-must $ m-may $ m-not $ m-extensionDITContentRule )
)
+# --- MetaDITContentRule objectclass ------------------------------------------
+objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.10
+ NAME 'metaSyntaxChecker'
+ DESC 'Meta definition of the SyntaxChecker object'
+ SUP metaTop
+ STRUCTURAL
+ MUST ( m-oid $ m-fqcn )
+ MAY m-bytecode
+)
+
+# --- MetaDITContentRule objectclass ------------------------------------------
+objectclass ( 1.3.6.1.4.1.18060.0.4.0.3.11
+ NAME 'metaSchema'
+ DESC 'A schema object under which meta schema definitions are found'
+ SUP metaTop
+ STRUCTURAL
+ MUST cn
+)
+
# =============================================================================
# AttributeTypes
# =============================================================================
@@ -416,5 +439,20 @@
DESC 'The matchingRule attribute syntax '
EQUALITY numericOidMatch
SYNTAX 1.3.6.1.4.1.18060.0.4.0.0.2
+ SINGLE-VALUE
+)
+
+# --- m-fqcn AttributeType --------------------------------
+attributetype ( 1.3.6.1.4.1.18060.0.4.0.2.32 NAME 'm-fqcn'
+ DESC 'The fully qualified class name of a code based schema entity'
+ EQUALITY caseExactMatch
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.26
+ SINGLE-VALUE
+)
+
+# --- m-bytecode AttributeType --------------------------------
+attributetype ( 1.3.6.1.4.1.18060.0.4.0.2.33 NAME 'm-bytecode'
+ DESC 'The Java bytecode for a code based schema entity'
+ SYNTAX 1.3.6.1.4.1.1466.115.121.1.5
SINGLE-VALUE
)