You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2011/01/31 17:11:54 UTC
svn commit: r1065663 - in /directory/shared/trunk:
ldap-schema/src/test/java/org/apache/directory/shared/ldap/schemaloader/
ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/
ldap/src/main/java/org/apache/directory/shared/ldap/model/s...
Author: pamarcelot
Date: Mon Jan 31 16:11:54 2011
New Revision: 1065663
URL: http://svn.apache.org/viewvc?rev=1065663&view=rev
Log:
Added a new specific Exception for handling the errors during schema checking by the SchemaManager.
Updated the AttributeType and ObjectClass classes to use this new exception.
Added:
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaException.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaExceptionCodes.java
Modified:
directory/shared/trunk/ldap-schema/src/test/java/org/apache/directory/shared/ldap/schemaloader/SchemaManagerAddTest.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributeType.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/ObjectClass.java
Modified: directory/shared/trunk/ldap-schema/src/test/java/org/apache/directory/shared/ldap/schemaloader/SchemaManagerAddTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/test/java/org/apache/directory/shared/ldap/schemaloader/SchemaManagerAddTest.java?rev=1065663&r1=1065662&r2=1065663&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/test/java/org/apache/directory/shared/ldap/schemaloader/SchemaManagerAddTest.java (original)
+++ directory/shared/trunk/ldap-schema/src/test/java/org/apache/directory/shared/ldap/schemaloader/SchemaManagerAddTest.java Mon Jan 31 16:11:54 2011
@@ -37,6 +37,7 @@ import org.apache.directory.junit.tools.
import org.apache.directory.junit.tools.ConcurrentJunitRunner;
import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.exception.LdapAttributeInUseException;
+import org.apache.directory.shared.ldap.model.exception.LdapSchemaException;
import org.apache.directory.shared.ldap.model.exception.LdapUnwillingToPerformException;
import org.apache.directory.shared.ldap.model.exception.LdapProtocolErrorException;
import org.apache.directory.shared.ldap.model.schema.AttributeType;
@@ -230,7 +231,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isATPresent( schemaManager, "1.1.0" ) );
assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
@@ -335,7 +336,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isATPresent( schemaManager, "1.1.0" ) );
assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
@@ -369,7 +370,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isATPresent( schemaManager, "1.1.0" ) );
assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
@@ -402,7 +403,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isATPresent( schemaManager, "1.1.0" ) );
assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
@@ -461,7 +462,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isATPresent( schemaManager, "1.1.0" ) );
assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
@@ -519,7 +520,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isATPresent( schemaManager, "1.1.0" ) );
assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
@@ -551,7 +552,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isATPresent( schemaManager, "1.1.0" ) );
assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
@@ -747,7 +748,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isATPresent( schemaManager, "1.1.0" ) );
assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
@@ -779,7 +780,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isATPresent( schemaManager, "1.1.0" ) );
assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
@@ -811,7 +812,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException);
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isATPresent( schemaManager, "1.1.0" ) );
assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
@@ -1139,7 +1140,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapUnwillingToPerformException);
+ assertTrue( error instanceof LdapUnwillingToPerformException );
// Check that the new MR has been injected
assertFalse( isMRPresent( schemaManager, "1.1.0" ) );
@@ -1342,7 +1343,7 @@ public class SchemaManagerAddTest
assertEquals( 1, schemaManager.getErrors().size() );
Throwable error = schemaManager.getErrors().get( 0 );
- assertTrue( error instanceof LdapAttributeInUseException);
+ assertTrue( error instanceof LdapAttributeInUseException );
assertFalse( isOCPresent( schemaManager, "1.1.0" ) );
@@ -1397,7 +1398,7 @@ public class SchemaManagerAddTest
assertEquals( 1, schemaManager.getErrors().size() );
Throwable error = schemaManager.getErrors().get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1424,7 +1425,7 @@ public class SchemaManagerAddTest
assertEquals( 1, schemaManager.getErrors().size() );
Throwable error = schemaManager.getErrors().get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1449,7 +1450,7 @@ public class SchemaManagerAddTest
assertFalse( schemaManager.add( objectClass ) );
assertEquals( 1, schemaManager.getErrors().size() );
- assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapProtocolErrorException );
+ assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1474,7 +1475,7 @@ public class SchemaManagerAddTest
assertFalse( schemaManager.add( objectClass ) );
assertEquals( 1, schemaManager.getErrors().size() );
- assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapProtocolErrorException );
+ assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1501,7 +1502,7 @@ public class SchemaManagerAddTest
assertFalse( schemaManager.add( objectClass ) );
assertEquals( 1, schemaManager.getErrors().size() );
- assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapProtocolErrorException );
+ assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1529,7 +1530,7 @@ public class SchemaManagerAddTest
assertFalse( schemaManager.add( objectClassMust ) );
assertEquals( 1, schemaManager.getErrors().size() );
- assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapProtocolErrorException );
+ assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1544,7 +1545,7 @@ public class SchemaManagerAddTest
assertFalse( schemaManager.add( objectClassMay ) );
assertEquals( 1, schemaManager.getErrors().size() );
- assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapProtocolErrorException );
+ assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1667,7 +1668,7 @@ public class SchemaManagerAddTest
assertFalse( schemaManager.add( objectClass ) );
- assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapProtocolErrorException );
+ assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1693,7 +1694,7 @@ public class SchemaManagerAddTest
assertFalse( schemaManager.add( objectClass ) );
- assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapProtocolErrorException );
+ assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1719,7 +1720,7 @@ public class SchemaManagerAddTest
assertFalse( schemaManager.add( objectClass ) );
- assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapProtocolErrorException );
+ assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1745,7 +1746,7 @@ public class SchemaManagerAddTest
assertFalse( schemaManager.add( objectClass ) );
- assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapProtocolErrorException );
+ assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
@@ -1771,7 +1772,7 @@ public class SchemaManagerAddTest
assertFalse( schemaManager.add( objectClass ) );
- assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapProtocolErrorException );
+ assertTrue( schemaManager.getErrors().get( 0 ) instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.1" ) );
Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaException.java?rev=1065663&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaException.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaException.java Mon Jan 31 16:11:54 2011
@@ -0,0 +1,214 @@
+/*
+ * 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.shared.ldap.model.exception;
+
+
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+import org.apache.directory.shared.ldap.model.schema.SchemaObject;
+
+
+/**
+ * A subclass of {@link LdapException} which is used to report issues
+ * during the integrity check of the schema by the {@link SchemaManager}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class LdapSchemaException extends LdapException
+{
+ /** The serial version UUID */
+ static final long serialVersionUID = 1L;
+
+ /** The code of the exception */
+ private LdapSchemaExceptionCodes code;
+
+ /** The 'source' schema object */
+ private SchemaObject source;
+
+ /** The 'other' schema object */
+ private SchemaObject other;
+
+
+ /**
+ * Creates a new instance of LdapSchemaException.
+ */
+ public LdapSchemaException()
+ {
+ super();
+ }
+
+
+ /**
+ * Creates a new instance of LdapSchemaException.
+ *
+ * @param explanation
+ * The message associated with the exception
+ */
+ public LdapSchemaException( String explanation )
+ {
+ super( explanation );
+ }
+
+
+ /**
+ * Creates a new instance of LdapSchemaException.
+ *
+ * @param code
+ * The code of the exception
+ * @param source
+ * The 'source' schema object
+ * @param other
+ * The 'other' schema object
+ * @param explanation
+ * The message associated with the exception
+ */
+ public LdapSchemaException( LdapSchemaExceptionCodes code, SchemaObject source, SchemaObject other,
+ String explanation )
+ {
+ super( explanation );
+ this.code = code;
+ this.source = source;
+ this.other = other;
+ }
+
+
+ /**
+ * Creates a new instance of LdapSchemaException.
+ *
+ * @param code
+ * The code of the exception
+ * @param source
+ * The 'source' schema object
+ * @param explanation
+ * The message associated with the exception
+ */
+ public LdapSchemaException( LdapSchemaExceptionCodes code, SchemaObject source, String explanation )
+ {
+ super( explanation );
+ this.code = code;
+ this.source = source;
+ }
+
+
+ /**
+ * Creates a new instance of LdapSchemaException.
+ *
+ * @param code
+ * The code of the exception
+ * @param source
+ * The 'source' schema object
+ * @param other
+ * The 'other' schema object
+ */
+ public LdapSchemaException( LdapSchemaExceptionCodes code, SchemaObject source, SchemaObject other )
+ {
+ super();
+ this.code = code;
+ this.source = source;
+ this.other = other;
+ }
+
+
+ /**
+ * Creates a new instance of LdapSchemaException.
+ *
+ * @param code
+ * The code of the exception
+ * @param source
+ * The 'source' schema object
+ */
+ public LdapSchemaException( LdapSchemaExceptionCodes code, SchemaObject source )
+ {
+ super();
+ this.code = code;
+ this.source = source;
+ }
+
+
+ /**
+ * Gets the code of the exception.
+ *
+ * @return
+ * the code of the exception
+ */
+ public LdapSchemaExceptionCodes getCode()
+ {
+ return code;
+ }
+
+
+ /**
+ * Sets the code of the exception.
+ *
+ * @param code
+ * the code of the exception
+ */
+ public void setCode( LdapSchemaExceptionCodes code )
+ {
+ this.code = code;
+ }
+
+
+ /**
+ * Gets the 'source' schema object.
+ *
+ * @return
+ * the 'source' schema object
+ */
+ public SchemaObject getSource()
+ {
+ return source;
+ }
+
+
+ /**
+ * Sets the 'source' schema object.
+ *
+ * @param source
+ * the 'source' schema object
+ */
+ public void setSource( SchemaObject source )
+ {
+ this.source = source;
+ }
+
+
+ /**
+ * Gets the 'other' schema object.
+ *
+ * @return
+ * the 'other' schema object
+ */
+ public SchemaObject getOther()
+ {
+ return other;
+ }
+
+
+ /**
+ * Sets the 'other' schema object.
+ *
+ * @param other
+ * the 'other' schema object
+ */
+ public void setOther( SchemaObject other )
+ {
+ this.other = other;
+ }
+}
Added: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaExceptionCodes.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaExceptionCodes.java?rev=1065663&view=auto
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaExceptionCodes.java (added)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaExceptionCodes.java Mon Jan 31 16:11:54 2011
@@ -0,0 +1,106 @@
+/*
+ * 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.shared.ldap.model.exception;
+
+
+import org.apache.directory.shared.ldap.model.schema.SchemaManager;
+
+
+/**
+ * This enum contains all the various codes that can be used to report issues
+ * during the integrity check of the schema by the {@link SchemaManager}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public enum LdapSchemaExceptionCodes
+{
+ // Codes for Attribute Type
+
+ /** Characterizing an AT with a nonexistent superior */
+ AT_NONEXISTENT_SUPERIOR,
+
+ /** Characterizing an AT sub-typing a Collective AT */
+ AT_CANNOT_SUBTYPE_COLLECTIVE_AT,
+
+ /** Characterizing an AT containing a cycle in its type hierarchy */
+ AT_CYCLE_TYPE_HIERARCHY,
+
+ /** Characterizing an AT with a nonexistent syntax */
+ AT_NONEXISTENT_SYNTAX,
+
+ /** Characterizing an AT has no syntax and no superior */
+ AT_SYNTAX_OR_SUPERIOR_REQUIRED,
+
+ /** Characterizing an AT with a nonexistent equality matching rule */
+ AT_NONEXISTENT_EQUALITY_MATCHING_RULE,
+
+ /** Characterizing an AT with a nonexistent ordering matching rule */
+ AT_NONEXISTENT_ORDERING_MATCHING_RULE,
+
+ /** Characterizing an AT with a nonexistent substring matching rule */
+ AT_NONEXISTENT_SUBSTRING_MATCHING_RULE,
+
+ /** Characterizing an AT which has a different usage than its superior */
+ AT_MUST_HAVE_SAME_USAGE_THAN_SUPERIOR,
+
+ /** Characterizing an AT which has a 'userApplications' usage but is not user modifiable */
+ AT_USER_APPLICATIONS_USAGE_MUST_BE_USER_MODIFIABLE,
+
+ /** Characterizing an AT which is collective but does not have a 'userApplications' usage */
+ AT_COLLECTIVE_MUST_HAVE_USER_APPLICATIONS_USAGE,
+
+ /** Characterizing an AT which is collective and is single-valued */
+ AT_COLLECTIVE_CANNOT_BE_SINGLE_VALUED,
+
+ // Codes for Object Class
+
+ /** Characterizing an abstract OC which inherits from an OC not being abstract */
+ OC_ABSTRACT_MUST_INHERIT_FROM_ABSTRACT_OC,
+
+ /** Characterizing an auxiliary OC which inherits from a structural OC */
+ OC_AUXILIARY_CANNOT_INHERIT_FROM_STRUCTURAL_OC,
+
+ /** Characterizing a structural OC which inherits from an auxiliary OC */
+ OC_STRUCTURAL_CANNOT_INHERIT_FROM_AUXILIARY_OC,
+
+ /** Characterizing an OC with a nonexistent superior */
+ OC_NONEXISTENT_SUPERIOR,
+
+ /** Characterizing an OC with a collective AT in its must ATs list */
+ OC_COLLECTIVE_NOT_ALLOWED_IN_MUST,
+
+ /** Characterizing an OC with a collective AT in its may ATs list */
+ OC_COLLECTIVE_NOT_ALLOWED_IN_MAY,
+
+ /** Characterizing an OC with a duplicated AT in its must ATs list */
+ OC_DUPLICATE_AT_IN_MUST,
+
+ /** Characterizing an OC with a duplicated AT in its may ATs list */
+ OC_DUPLICATE_AT_IN_MAY,
+
+ /** Characterizing an OC with a nonexistent AT in its must ATs list */
+ OC_NONEXISTENT_MUST_AT,
+
+ /** Characterizing an OC with a nonexistent AT in its may ATs list */
+ OC_NONEXISTENT_MAY_AT,
+
+ /** Characterizing an OC with a duplicated AT in its may and must ATs list */
+ OC_DUPLICATE_AT_IN_MAY_AND_MUST,
+}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributeType.java?rev=1065663&r1=1065662&r2=1065663&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributeType.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/AttributeType.java Mon Jan 31 16:11:54 2011
@@ -26,9 +26,8 @@ import java.util.Set;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.exception.LdapProtocolErrorException;
-import org.apache.directory.shared.ldap.model.exception.LdapSchemaViolationException;
-import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.model.exception.LdapSchemaException;
+import org.apache.directory.shared.ldap.model.exception.LdapSchemaExceptionCodes;
import org.apache.directory.shared.ldap.model.schema.registries.AttributeTypeRegistry;
import org.apache.directory.shared.ldap.model.schema.registries.Registries;
import org.slf4j.Logger;
@@ -225,7 +224,8 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04303, superiorOid, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.AT_NONEXISTENT_SUPERIOR,
+ this, msg );
errors.add( error );
LOG.info( msg );
@@ -240,7 +240,9 @@ public class AttributeType extends Abstr
{
String msg = I18n.err( I18n.ERR_04482_CANNOT_SUBTYPE_COLLECTIVE, currentSuperior, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.AT_CANNOT_SUBTYPE_COLLECTIVE_AT,
+ this, msg );
errors.add( error );
LOG.info( msg );
return false;
@@ -282,7 +284,8 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04304, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.AT_CYCLE_TYPE_HIERARCHY,
+ this, msg );
errors.add( error );
LOG.info( msg );
isOk = false;
@@ -305,7 +308,8 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04305, superiorOid, getName() );
- Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.AT_NONEXISTENT_SUPERIOR,
+ this, msg );
errors.add( error );
LOG.info( msg );
@@ -339,7 +343,8 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04306, syntaxOid, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.AT_NONEXISTENT_SYNTAX,
+ this, msg );
errors.add( error );
LOG.info( msg );
return;
@@ -355,7 +360,8 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04306, syntaxOid, getName() );
- Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.AT_NONEXISTENT_SYNTAX,
+ this, msg );
errors.add( error );
LOG.info( msg );
return;
@@ -374,7 +380,8 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04307, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.AT_SYNTAX_OR_SUPERIOR_REQUIRED,
+ this, msg );
errors.add( error );
LOG.info( msg );
return;
@@ -402,7 +409,9 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04308, equalityOid, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.AT_NONEXISTENT_EQUALITY_MATCHING_RULE,
+ this, msg );
errors.add( error );
LOG.info( msg );
return;
@@ -417,7 +426,9 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04309, equalityOid, getName() );
- Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.AT_NONEXISTENT_EQUALITY_MATCHING_RULE,
+ this, msg );
errors.add( error );
LOG.info( msg );
}
@@ -452,7 +463,9 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04310, orderingOid, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.AT_NONEXISTENT_ORDERING_MATCHING_RULE,
+ this, msg );
errors.add( error );
LOG.info( msg );
return;
@@ -467,7 +480,9 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04311, orderingOid, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.AT_NONEXISTENT_ORDERING_MATCHING_RULE,
+ this, msg );
errors.add( error );
LOG.info( msg );
}
@@ -503,7 +518,9 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04312, substringOid, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.AT_NONEXISTENT_SUBSTRING_MATCHING_RULE,
+ this, msg );
errors.add( error );
LOG.info( msg );
return;
@@ -518,7 +535,9 @@ public class AttributeType extends Abstr
// Not allowed.
String msg = I18n.err( I18n.ERR_04313, substringOid, getName() );
- Throwable error = new LdapSchemaViolationException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.AT_NONEXISTENT_SUBSTRING_MATCHING_RULE,
+ this, msg );
errors.add( error );
LOG.info( msg );
return;
@@ -547,7 +566,8 @@ public class AttributeType extends Abstr
// This is an error
String msg = I18n.err( I18n.ERR_04314, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.AT_MUST_HAVE_SAME_USAGE_THAN_SUPERIOR,
+ this, msg );
errors.add( error );
LOG.info( msg );
return;
@@ -559,7 +579,9 @@ public class AttributeType extends Abstr
// Cannot have a not user modifiable AT which is not an operational AT
String msg = I18n.err( I18n.ERR_04315, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.AT_USER_APPLICATIONS_USAGE_MUST_BE_USER_MODIFIABLE,
+ this, msg );
errors.add( error );
LOG.info( msg );
}
@@ -582,7 +604,9 @@ public class AttributeType extends Abstr
// An AttributeType which is collective must be a USER attributeType
String msg = I18n.err( I18n.ERR_04316, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.AT_COLLECTIVE_MUST_HAVE_USER_APPLICATIONS_USAGE,
+ this, msg );
errors.add( error );
LOG.info( msg );
}
@@ -592,7 +616,8 @@ public class AttributeType extends Abstr
// A collective attribute must be multi-valued
String msg = I18n.err( I18n.ERR_04483_COLLECTIVE_NOT_MULTI_VALUED, getName() );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.AT_COLLECTIVE_CANNOT_BE_SINGLE_VALUED,
+ this, msg );
errors.add( error );
LOG.info( msg );
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/ObjectClass.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/ObjectClass.java?rev=1065663&r1=1065662&r2=1065663&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/ObjectClass.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/ObjectClass.java Mon Jan 31 16:11:54 2011
@@ -25,10 +25,11 @@ import java.util.List;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.exception.LdapProtocolErrorException;
+import org.apache.directory.shared.ldap.model.exception.LdapSchemaException;
+import org.apache.directory.shared.ldap.model.exception.LdapSchemaExceptionCodes;
import org.apache.directory.shared.ldap.model.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.shared.ldap.model.schema.registries.Registries;
import org.apache.directory.shared.ldap.model.schema.registries.ObjectClassRegistry;
+import org.apache.directory.shared.ldap.model.schema.registries.Registries;
/**
@@ -145,7 +146,9 @@ public class ObjectClass extends Abstrac
// An ABSTRACT OC can only inherit from ABSTRACT OCs
String msg = I18n.err( I18n.ERR_04318, oid, superior.getObjectType(), superior );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.OC_ABSTRACT_MUST_INHERIT_FROM_ABSTRACT_OC,
+ this, msg );
errors.add( error );
return;
}
@@ -158,7 +161,9 @@ public class ObjectClass extends Abstrac
// An AUXILIARY OC cannot inherit from STRUCTURAL OCs
String msg = I18n.err( I18n.ERR_04319, oid, superior );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.OC_AUXILIARY_CANNOT_INHERIT_FROM_STRUCTURAL_OC,
+ this, msg );
errors.add( error );
return;
}
@@ -171,7 +176,9 @@ public class ObjectClass extends Abstrac
// A STRUCTURAL OC cannot inherit from AUXILIARY OCs
String msg = I18n.err( I18n.ERR_04320, oid, superior );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.OC_STRUCTURAL_CANNOT_INHERIT_FROM_AUXILIARY_OC,
+ this, msg );
errors.add( error );
return;
}
@@ -186,7 +193,8 @@ public class ObjectClass extends Abstrac
// Cannot find the OC
String msg = I18n.err( I18n.ERR_04321, oid, superiorName );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.OC_NONEXISTENT_SUPERIOR,
+ this, msg );
errors.add( error );
return;
}
@@ -214,7 +222,9 @@ public class ObjectClass extends Abstrac
// Collective Attributes are not allowed in MAY or MUST
String msg = I18n.err( I18n.ERR_04485_COLLECTIVE_NOT_ALLOWED_IN_MAY, mayAttributeTypeName, oid );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.OC_COLLECTIVE_NOT_ALLOWED_IN_MAY,
+ this, msg );
errors.add( error );
break;
}
@@ -223,7 +233,9 @@ public class ObjectClass extends Abstrac
{
// Already registered : this is an error
String msg = I18n.err( I18n.ERR_04322, oid, mayAttributeTypeName );
- Throwable error = new LdapProtocolErrorException( msg );
+
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.OC_DUPLICATE_AT_IN_MAY,
+ this, msg );
errors.add( error );
break;
}
@@ -235,7 +247,8 @@ public class ObjectClass extends Abstrac
// Cannot find the AT
String msg = I18n.err( I18n.ERR_04323, oid, mayAttributeTypeName );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.OC_NONEXISTENT_MAY_AT,
+ this, msg );
errors.add( error );
break;
}
@@ -261,9 +274,12 @@ public class ObjectClass extends Abstrac
if ( attributeType.isCollective() )
{
// Collective Attributes are not allowed in MAY or MUST
- String msg = I18n.err( I18n.ERR_04484_COLLECTIVE_NOT_ALLOWED_IN_MUST, mustAttributeTypeName, oid );
+ String msg = I18n.err( I18n.ERR_04484_COLLECTIVE_NOT_ALLOWED_IN_MUST, mustAttributeTypeName,
+ oid );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.OC_COLLECTIVE_NOT_ALLOWED_IN_MUST,
+ this, msg );
errors.add( error );
break;
}
@@ -273,7 +289,8 @@ public class ObjectClass extends Abstrac
// Already registered : this is an error
String msg = I18n.err( I18n.ERR_04324, oid, mustAttributeTypeName );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.OC_DUPLICATE_AT_IN_MUST,
+ this, msg );
errors.add( error );
break;
}
@@ -284,7 +301,9 @@ public class ObjectClass extends Abstrac
// Already registered : this is an error
String msg = I18n.err( I18n.ERR_04325, oid, mustAttributeTypeName );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.OC_DUPLICATE_AT_IN_MAY_AND_MUST,
+ this, msg );
errors.add( error );
break;
}
@@ -296,7 +315,8 @@ public class ObjectClass extends Abstrac
// Cannot find the AT
String msg = I18n.err( I18n.ERR_04326, oid, mustAttributeTypeName );
- Throwable error = new LdapProtocolErrorException( msg );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.OC_NONEXISTENT_MUST_AT,
+ this, msg );
errors.add( error );
break;
}