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 2007/01/17 22:50:09 UTC

svn commit: r497192 - in /directory/trunks/apacheds: constants/src/main/java/org/apache/directory/server/constants/ core/src/main/java/org/apache/directory/server/core/schema/

Author: akarasulu
Date: Wed Jan 17 13:50:08 2007
New Revision: 497192

URL: http://svn.apache.org/viewvc?view=rev&rev=497192
Log:
finishing up some functionality when schemas are created in the schema partition

Modified:
    directory/trunks/apacheds/constants/src/main/java/org/apache/directory/server/constants/CoreSchemaConstants.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java

Modified: directory/trunks/apacheds/constants/src/main/java/org/apache/directory/server/constants/CoreSchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/constants/src/main/java/org/apache/directory/server/constants/CoreSchemaConstants.java?view=diff&rev=497192&r1=497191&r2=497192
==============================================================================
--- directory/trunks/apacheds/constants/src/main/java/org/apache/directory/server/constants/CoreSchemaConstants.java (original)
+++ directory/trunks/apacheds/constants/src/main/java/org/apache/directory/server/constants/CoreSchemaConstants.java Wed Jan 17 13:50:08 2007
@@ -28,7 +28,6 @@
  */
 public interface CoreSchemaConstants
 {
-
     public static final String OU_AT = "ou";
-
+    public static final String ORGANIZATIONAL_UNIT_OC = "organizationalUnit";
 }

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java?view=diff&rev=497192&r1=497191&r2=497192
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSchemaHandler.java Wed Jan 17 13:50:08 2007
@@ -25,13 +25,17 @@
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
 
+import org.apache.directory.server.constants.CoreSchemaConstants;
 import org.apache.directory.server.constants.MetaSchemaConstants;
 import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.bootstrap.Schema;
 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.exception.LdapInvalidNameException;
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 
@@ -47,6 +51,7 @@
     private final PartitionSchemaLoader loader;
     private final Registries globalRegistries;
     private final AttributeType disabledAT;
+    private final String OU_OID;
     
 
     public MetaSchemaHandler( Registries globalRegistries, PartitionSchemaLoader loader ) 
@@ -56,6 +61,7 @@
         this.disabledAT = globalRegistries.getAttributeTypeRegistry()
             .lookup( MetaSchemaConstants.M_DISABLED_AT );
         this.loader = loader;
+        this.OU_OID = globalRegistries.getOidRegistry().getOid( CoreSchemaConstants.OU_AT );
     }
 
     
@@ -66,7 +72,10 @@
         if ( disabledInMods != null )
         {
             disable( name, modOp, disabledInMods, ServerUtils.getAttribute( disabledAT, entry ) );
+            return;
         }
+        
+        throw new NotImplementedException();
     }
 
 
@@ -175,13 +184,18 @@
 
     public void add( LdapDN name, Attributes entry ) throws NamingException
     {
-        throw new NotImplementedException();
+        LdapDN parentDn = ( LdapDN ) name.clone();
+        parentDn.remove( parentDn.size() - 1 );
+        if ( parentDn.toNormName().equals( OU_OID + "=schema" ) )
+        {
+            throw new LdapInvalidNameException( "The parent dn of a schema should be ou=schema.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
     }
 
 
     public void delete( LdapDN name, Attributes entry ) throws NamingException
     {
-        throw new NotImplementedException();
     }
 
 
@@ -194,12 +208,14 @@
     public void move( LdapDN oriChildName, LdapDN newParentName, String newRn, boolean deleteOldRn, Attributes entry ) 
         throws NamingException
     {
-        throw new NotImplementedException();
+        throw new LdapOperationNotSupportedException( "Moving around schemas is not allowed.", 
+            ResultCodeEnum.UNWILLING_TO_PERFORM );
     }
 
 
     public void move( LdapDN oriChildName, LdapDN newParentName, Attributes entry ) throws NamingException
     {
-        throw new NotImplementedException();
+        throw new LdapOperationNotSupportedException( "Moving around schemas is not allowed.", 
+            ResultCodeEnum.UNWILLING_TO_PERFORM );
     }
 }

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java?view=diff&rev=497192&r1=497191&r2=497192
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java Wed Jan 17 13:50:08 2007
@@ -20,16 +20,23 @@
 package org.apache.directory.server.core.schema;
 
 
+import java.util.HashSet;
+import java.util.Set;
+
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 
+import org.apache.directory.server.constants.CoreSchemaConstants;
 import org.apache.directory.server.constants.MetaSchemaConstants;
 import org.apache.directory.server.constants.SystemSchemaConstants;
 import org.apache.directory.server.core.ServerUtils;
 import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.NotImplementedException;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
@@ -50,6 +57,8 @@
  */
 public class SchemaManager
 {
+    private static final Set<String> VALID_OU_VALUES = new HashSet<String>();
+
     private final PartitionSchemaLoader loader;
     private final MetaSchemaHandler metaSchemaHandler;
     private final Registries globalRegistries;
@@ -61,6 +70,21 @@
     private final MetaMatchingRuleHandler metaMatchingRuleHandler;
     private final MetaAttributeTypeHandler metaAttributeTypeHandler;
     private final MetaObjectClassHandler metaObjectClassHandler;
+    
+    
+    static 
+    {
+        VALID_OU_VALUES.add( "normalizers" );
+        VALID_OU_VALUES.add( "comparators" );
+        VALID_OU_VALUES.add( "syntaxcheckers" );
+        VALID_OU_VALUES.add( "syntaxes" );
+        VALID_OU_VALUES.add( "matchingrules" );
+        VALID_OU_VALUES.add( "attributetypes" );
+        VALID_OU_VALUES.add( "objectclasses" );
+        VALID_OU_VALUES.add( "nameforms" );
+        VALID_OU_VALUES.add( "ditcontentrules" );
+        VALID_OU_VALUES.add( "ditstructurerules" );
+    }
 
 
     public SchemaManager( Registries globalRegistries, PartitionSchemaLoader loader, SchemaPartitionDao dao ) 
@@ -92,7 +116,7 @@
         throw new NotImplementedException();
     }
 
-    
+
     public void add( LdapDN name, Attributes entry ) throws NamingException
     {
         Attribute oc = ServerUtils.getAttribute( objectClassAT, entry );
@@ -145,7 +169,27 @@
             return;
         }
 
-        throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
+        if ( AttributeUtils.containsValue( oc, CoreSchemaConstants.ORGANIZATIONAL_UNIT_OC, objectClassAT ) )
+        {
+            if ( name.size() != 3 )
+            {
+                throw new LdapInvalidNameException( 
+                    "Schema entity containers of objectClass organizationalUnit should be 3 name components in length.", 
+                    ResultCodeEnum.NAMING_VIOLATION );
+            }
+            
+            String ouValue = ( String ) name.getRdn().getValue();
+            ouValue = ouValue.trim().toLowerCase();
+            if ( ! VALID_OU_VALUES.contains( ouValue ) )
+            {
+                throw new LdapInvalidNameException( 
+                    "Expecting organizationalUnit with one of the following names: " + VALID_OU_VALUES, 
+                    ResultCodeEnum.NAMING_VIOLATION );
+            }
+            return;
+        }
+
+        throw new LdapNamingException( ResultCodeEnum.UNWILLING_TO_PERFORM );
     }
     
 
@@ -201,7 +245,27 @@
             return;
         }
 
-        throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
+        if ( AttributeUtils.containsValue( oc, CoreSchemaConstants.ORGANIZATIONAL_UNIT_OC, objectClassAT ) )
+        {
+            if ( name.size() != 3 )
+            {
+                throw new LdapNamingException( 
+                    "Only schema entity containers of objectClass organizationalUnit with 3 name components in length" +
+                    " can be deleted.", ResultCodeEnum.UNWILLING_TO_PERFORM );
+            }
+            
+            String ouValue = ( String ) name.getRdn().getValue();
+            ouValue = ouValue.trim().toLowerCase();
+            if ( ! VALID_OU_VALUES.contains( ouValue ) )
+            {
+                throw new LdapInvalidNameException( 
+                    "Can only delete organizationalUnit entity containers with one of the following names: " 
+                    + VALID_OU_VALUES, ResultCodeEnum.NAMING_VIOLATION );
+            }
+            return;
+        }
+
+        throw new LdapNamingException( ResultCodeEnum.UNWILLING_TO_PERFORM );
     }
     
 
@@ -258,7 +322,7 @@
             return;
         }
 
-        throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
+        throw new LdapNamingException( ResultCodeEnum.UNWILLING_TO_PERFORM );
     }
 
 
@@ -315,7 +379,7 @@
             return;
         }
 
-        throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
+        throw new LdapNamingException( ResultCodeEnum.UNWILLING_TO_PERFORM );
     }
 
 
@@ -371,7 +435,7 @@
             return;
         }
 
-        throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
+        throw new LdapNamingException( ResultCodeEnum.UNWILLING_TO_PERFORM );
     }
 
 
@@ -427,7 +491,7 @@
             return;
         }
 
-        throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
+        throw new LdapNamingException( ResultCodeEnum.UNWILLING_TO_PERFORM );
     }
 
 
@@ -484,6 +548,6 @@
             return;
         }
 
-        throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
+        throw new LdapNamingException( ResultCodeEnum.UNWILLING_TO_PERFORM );
     }
 }