Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 12249 invoked from network); 17 Jan 2007 21:51:15 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Jan 2007 21:51:15 -0000 Received: (qmail 8626 invoked by uid 500); 17 Jan 2007 21:51:21 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 8574 invoked by uid 500); 17 Jan 2007 21:51:21 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 8563 invoked by uid 99); 17 Jan 2007 21:51:21 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jan 2007 13:51:21 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Jan 2007 13:51:13 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id D6C181A981A; Wed, 17 Jan 2007 13:50:09 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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/ Date: Wed, 17 Jan 2007 21:50:09 -0000 To: commits@directory.apache.org From: akarasulu@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070117215009.D6C181A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 VALID_OU_VALUES = new HashSet(); + 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 ); } }