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/02/01 13:59:28 UTC
svn commit: r1066036 - in /directory/shared/trunk:
ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/
ldap-schema/src/test/java/org/apache/directory/shared/ldap/schemaloader/
ldap/src/main/java/org/apache/directory/shared/ld...
Author: pamarcelot
Date: Tue Feb 1 12:59:27 2011
New Revision: 1066036
URL: http://svn.apache.org/viewvc?rev=1066036&view=rev
Log:
Updated schema related classes to use this new LdapSchemaException.
Modified:
directory/shared/trunk/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java
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/exception/LdapSchemaExceptionCodes.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRule.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/DefaultSchemaObjectRegistry.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java
Modified: directory/shared/trunk/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java?rev=1066036&r1=1066035&r2=1066036&view=diff
==============================================================================
--- directory/shared/trunk/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java (original)
+++ directory/shared/trunk/ldap-schema/src/main/java/org/apache/directory/shared/ldap/schemamanager/impl/DefaultSchemaManager.java Tue Feb 1 12:59:27 2011
@@ -36,6 +36,8 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
import org.apache.directory.shared.ldap.model.exception.LdapOtherException;
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.exception.LdapUnwillingToPerformException;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.model.name.Dn;
@@ -122,7 +124,7 @@ public class DefaultSchemaManager implem
/** Two flags for RELAXED and STRICT, this is STRICT */
public static final boolean STRICT = false;
-
+
/** Two flags for RELAXED and STRICT, this is RELAXED */
public static final boolean RELAXED = true;
@@ -258,7 +260,7 @@ public class DefaultSchemaManager implem
private void deleteSchemaObjects( Schema schema, Registries registries ) throws LdapException
{
Map<String, Set<SchemaObjectWrapper>> schemaObjects = registries.getObjectBySchemaName();
- Set<SchemaObjectWrapper> content = schemaObjects.get( Strings.toLowerCase(schema.getSchemaName()) );
+ Set<SchemaObjectWrapper> content = schemaObjects.get( Strings.toLowerCase( schema.getSchemaName() ) );
List<SchemaObject> toBeDeleted = new ArrayList<SchemaObject>();
@@ -1500,7 +1502,7 @@ public class DefaultSchemaManager implem
*/
public AttributeType lookupAttributeTypeRegistry( String oid ) throws LdapException
{
- return registries.getAttributeTypeRegistry().lookup( Strings.toLowerCase(oid).trim() );
+ return registries.getAttributeTypeRegistry().lookup( Strings.toLowerCase( oid ).trim() );
}
@@ -1511,7 +1513,7 @@ public class DefaultSchemaManager implem
{
try
{
- return registries.getAttributeTypeRegistry().lookup( Strings.toLowerCase(oid).trim() );
+ return registries.getAttributeTypeRegistry().lookup( Strings.toLowerCase( oid ).trim() );
}
catch ( LdapException lnsae )
{
@@ -1534,7 +1536,7 @@ public class DefaultSchemaManager implem
*/
public MatchingRule lookupMatchingRuleRegistry( String oid ) throws LdapException
{
- return registries.getMatchingRuleRegistry().lookup( Strings.toLowerCase(oid).trim() );
+ return registries.getMatchingRuleRegistry().lookup( Strings.toLowerCase( oid ).trim() );
}
@@ -1552,7 +1554,7 @@ public class DefaultSchemaManager implem
*/
public ObjectClass lookupObjectClassRegistry( String oid ) throws LdapException
{
- return registries.getObjectClassRegistry().lookup( Strings.toLowerCase(oid).trim() );
+ return registries.getObjectClassRegistry().lookup( Strings.toLowerCase( oid ).trim() );
}
@@ -1561,7 +1563,7 @@ public class DefaultSchemaManager implem
*/
public LdapSyntax lookupLdapSyntaxRegistry( String oid ) throws LdapException
{
- return registries.getLdapSyntaxRegistry().lookup( Strings.toLowerCase(oid).trim() );
+ return registries.getLdapSyntaxRegistry().lookup( Strings.toLowerCase( oid ).trim() );
}
@@ -1624,9 +1626,9 @@ public class DefaultSchemaManager implem
*/
private String getSchemaName( SchemaObject schemaObject )
{
- String schemaName = Strings.toLowerCase(schemaObject.getSchemaName());
+ String schemaName = Strings.toLowerCase( schemaObject.getSchemaName() );
- if ( Strings.isEmpty(schemaName) )
+ if ( Strings.isEmpty( schemaName ) )
{
return MetaSchemaConstants.SCHEMA_OTHER;
}
@@ -1702,7 +1704,8 @@ public class DefaultSchemaManager implem
// The new schemaObject's OID must not already exist
if ( checkOidExist( copy ) )
{
- Throwable error = new LdapProtocolErrorException( I18n.err( I18n.ERR_11008, schemaObject.getOid() ) );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.OID_ALREADY_REGISTERED,
+ schemaObject, I18n.err( I18n.ERR_11008, schemaObject.getOid() ) );
errors.add( error );
return false;
@@ -1713,9 +1716,9 @@ public class DefaultSchemaManager implem
if ( schemaName == null )
{
- // The schema associated with the SchemzaObject does not exist. This is not valid.
- Throwable error = new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM, I18n.err(
- I18n.ERR_11009, schemaObject.getOid(), copy.getSchemaName() ) );
+ // The schema associated with the SchemaaObject does not exist. This is not valid.
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.NONEXISTENT_SCHEMA,
+ schemaObject, I18n.err( I18n.ERR_11009, schemaObject.getOid(), copy.getSchemaName() ) );
errors.add( error );
return false;
@@ -1773,7 +1776,7 @@ public class DefaultSchemaManager implem
{
// We have some error : reject the addition and get out
String msg = "Cannot add the SchemaObject " + copy.getOid() + " into the registries, "
- + "the resulting registries would be inconsistent :" + Strings.listToString(errors);
+ + "the resulting registries would be inconsistent :" + Strings.listToString( errors );
LOG.info( msg );
return false;
@@ -1826,7 +1829,7 @@ public class DefaultSchemaManager implem
if ( ( referencing != null ) && !referencing.isEmpty() )
{
- String msg = I18n.err( I18n.ERR_11012, schemaObject.getOid(), Strings.setToString(referencing) );
+ String msg = I18n.err( I18n.ERR_11012, schemaObject.getOid(), Strings.setToString( referencing ) );
Throwable error = new LdapProtocolErrorException( msg );
errors.add( error );
@@ -1883,7 +1886,7 @@ public class DefaultSchemaManager implem
{
// We have some error : reject the deletion and get out
String msg = "Cannot delete the SchemaObject " + schemaObject.getOid() + " from the registries, "
- + "the resulting registries would be inconsistent :" + Strings.listToString(errors);
+ + "the resulting registries would be inconsistent :" + Strings.listToString( errors );
LOG.info( msg );
return false;
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=1066036&r1=1066035&r2=1066036&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 Tue Feb 1 12:59:27 2011
@@ -36,10 +36,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.directory.junit.tools.Concurrent;
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;
import org.apache.directory.shared.ldap.model.schema.LdapComparator;
import org.apache.directory.shared.ldap.model.schema.LdapSyntax;
@@ -608,7 +605,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
// The AT must be there
assertTrue( isATPresent( schemaManager, "2.5.18.4" ) );
@@ -645,7 +642,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapAttributeInUseException );
+ assertTrue( error instanceof LdapSchemaException );
// The AT must not be there
assertFalse( isATPresent( schemaManager, "1.1.1.0" ) );
@@ -986,7 +983,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isMRPresent( schemaManager, "1.1.0" ) );
@@ -1015,7 +1012,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
// Check that the existing MR has not been replaced
assertTrue( isMRPresent( schemaManager, "2.5.13.0" ) );
@@ -1049,7 +1046,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapAttributeInUseException );
+ assertTrue( error instanceof LdapSchemaException );
assertEquals( mrrSize, schemaManager.getMatchingRuleRegistry().size() );
assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
@@ -1111,7 +1108,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertEquals( mrrSize, schemaManager.getMatchingRuleRegistry().size() );
assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
@@ -1140,7 +1137,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapUnwillingToPerformException );
+ assertTrue( error instanceof LdapSchemaException );
// Check that the new MR has been injected
assertFalse( isMRPresent( schemaManager, "1.1.0" ) );
@@ -1314,7 +1311,7 @@ public class SchemaManagerAddTest
assertEquals( 1, schemaManager.getErrors().size() );
Throwable error = schemaManager.getErrors().get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
ObjectClass added = schemaManager.lookupObjectClassRegistry( "2.5.17.0" );
@@ -1343,7 +1340,7 @@ public class SchemaManagerAddTest
assertEquals( 1, schemaManager.getErrors().size() );
Throwable error = schemaManager.getErrors().get( 0 );
- assertTrue( error instanceof LdapAttributeInUseException );
+ assertTrue( error instanceof LdapSchemaException );
assertFalse( isOCPresent( schemaManager, "1.1.0" ) );
@@ -1616,7 +1613,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" ) );
@@ -1642,7 +1639,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" ) );
@@ -1845,7 +1842,7 @@ public class SchemaManagerAddTest
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" ) );
@@ -1906,7 +1903,7 @@ public class SchemaManagerAddTest
assertEquals( 1, errors.size() );
Throwable error = errors.get( 0 );
- assertTrue( error instanceof LdapProtocolErrorException );
+ assertTrue( error instanceof LdapSchemaException );
assertEquals( sSize, schemaManager.getLdapSyntaxRegistry().size() );
assertEquals( goidSize, schemaManager.getGlobalOidRegistry().size() );
}
Modified: 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=1066036&r1=1066035&r2=1066036&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaExceptionCodes.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/exception/LdapSchemaExceptionCodes.java Tue Feb 1 12:59:27 2011
@@ -31,6 +31,17 @@ import org.apache.directory.shared.ldap.
*/
public enum LdapSchemaExceptionCodes
{
+ // Codes for all Schema Objects
+
+ /** Characterizing a SO with an OID being already registered */
+ OID_ALREADY_REGISTERED,
+
+ /** Characterizing a SO with a name being already registered */
+ NAME_ALREADY_REGISTERED,
+
+ /** Characterizing an SO with a nonexistent schema */
+ NONEXISTENT_SCHEMA,
+
// Codes for Attribute Type
/** Characterizing an AT with a nonexistent superior */
@@ -83,6 +94,9 @@ public enum LdapSchemaExceptionCodes
/** Characterizing an OC with a nonexistent superior */
OC_NONEXISTENT_SUPERIOR,
+ /** Characterizing an OC containing a cycle in its class hierarchy */
+ OC_CYCLE_CLASS_HIERARCHY,
+
/** Characterizing an OC with a collective AT in its must ATs list */
OC_COLLECTIVE_NOT_ALLOWED_IN_MUST,
@@ -103,4 +117,8 @@ public enum LdapSchemaExceptionCodes
/** Characterizing an OC with a duplicated AT in its may and must ATs list */
OC_DUPLICATE_AT_IN_MAY_AND_MUST,
+ // Codes for all Schema Objects
+
+ /** Characterizing a MR with a nonexistent syntax */
+ MR_NONEXISTENT_SYNTAX,
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRule.java?rev=1066036&r1=1066035&r2=1066036&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRule.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/MatchingRule.java Tue Feb 1 12:59:27 2011
@@ -22,12 +22,17 @@ package org.apache.directory.shared.ldap
import java.util.List;
+import javax.naming.NamingException;
+
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.comparators.ComparableComparator;
import org.apache.directory.shared.ldap.model.schema.normalizers.NoOpNormalizer;
import org.apache.directory.shared.ldap.model.schema.registries.Registries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
@@ -84,6 +89,9 @@ import org.apache.directory.shared.ldap.
@SuppressWarnings("PMD.OverrideBothEqualsAndHashcode")
public class MatchingRule extends AbstractSchemaObject
{
+ /** A logger for this class */
+ private static final Logger LOG = LoggerFactory.getLogger( MatchingRule.class );
+
/** The serialVersionUID */
private static final long serialVersionUID = 1L;
@@ -152,7 +160,12 @@ public class MatchingRule extends Abstra
catch ( LdapException ne )
{
// The Syntax is a mandatory element, it must exist.
- throw new LdapProtocolErrorException( I18n.err( I18n.ERR_04317 ) );
+ String msg = I18n.err( I18n.ERR_04317 );
+
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.MR_NONEXISTENT_SYNTAX,
+ this, msg );
+ errors.add( error );
+ LOG.info( msg );
}
/**
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/DefaultSchemaObjectRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/DefaultSchemaObjectRegistry.java?rev=1066036&r1=1066035&r2=1066036&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/DefaultSchemaObjectRegistry.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/DefaultSchemaObjectRegistry.java Tue Feb 1 12:59:27 2011
@@ -28,6 +28,8 @@ import org.apache.directory.shared.asn1.
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.exception.LdapAttributeInUseException;
import org.apache.directory.shared.ldap.model.exception.LdapException;
+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.LoadableSchemaObject;
import org.apache.directory.shared.ldap.model.schema.SchemaObject;
import org.apache.directory.shared.ldap.model.schema.SchemaObjectType;
@@ -78,7 +80,7 @@ public abstract class DefaultSchemaObjec
{
if ( !byName.containsKey( oid ) )
{
- return byName.containsKey( Strings.toLowerCase(oid) );
+ return byName.containsKey( Strings.toLowerCase( oid ) );
}
return true;
@@ -90,7 +92,7 @@ public abstract class DefaultSchemaObjec
*/
public String getSchemaName( String oid ) throws LdapException
{
- if ( !OID.isOID(oid) )
+ if ( !OID.isOID( oid ) )
{
String msg = I18n.err( I18n.ERR_04267 );
LOG.warn( msg );
@@ -165,7 +167,7 @@ public abstract class DefaultSchemaObjec
if ( schemaObject == null )
{
// let's try with trimming and lowercasing now
- schemaObject = byName.get( Strings.trim(Strings.toLowerCase(oid)) );
+ schemaObject = byName.get( Strings.trim( Strings.toLowerCase( oid ) ) );
}
if ( schemaObject == null )
@@ -195,7 +197,8 @@ public abstract class DefaultSchemaObjec
{
String msg = I18n.err( I18n.ERR_04270, schemaObjectType.name(), oid );
LOG.warn( msg );
- throw new LdapAttributeInUseException( msg );
+ throw new LdapSchemaException( LdapSchemaExceptionCodes.OID_ALREADY_REGISTERED,
+ schemaObject, msg );
}
byName.put( oid, schemaObject );
@@ -206,13 +209,14 @@ public abstract class DefaultSchemaObjec
*/
for ( String name : schemaObject.getNames() )
{
- String lowerName = Strings.trim(Strings.toLowerCase(name));
+ String lowerName = Strings.trim( Strings.toLowerCase( name ) );
if ( byName.containsKey( lowerName ) )
{
String msg = I18n.err( I18n.ERR_04271, schemaObjectType.name(), name );
LOG.warn( msg );
- throw new LdapAttributeInUseException( msg );
+ throw new LdapSchemaException( LdapSchemaExceptionCodes.NAME_ALREADY_REGISTERED,
+ schemaObject, msg );
}
else
{
@@ -284,7 +288,7 @@ public abstract class DefaultSchemaObjec
*/
for ( String name : schemaObject.getNames() )
{
- byName.remove( Strings.trim(Strings.toLowerCase(name)) );
+ byName.remove( Strings.trim( Strings.toLowerCase( name ) ) );
}
// And unregister the oid -> schemaObject relation
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java?rev=1066036&r1=1066035&r2=1066036&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/model/schema/registries/Registries.java Tue Feb 1 12:59:27 2011
@@ -32,6 +32,8 @@ import org.apache.directory.shared.i18n.
import org.apache.directory.shared.ldap.model.constants.MetaSchemaConstants;
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.exception.LdapSchemaViolationException;
import org.apache.directory.shared.ldap.model.exception.LdapUnwillingToPerformException;
import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
@@ -419,7 +421,7 @@ public class Registries implements Schem
*/
public Schema getLoadedSchema( String schemaName )
{
- return loadedSchemas.get( Strings.toLowerCase(schemaName) );
+ return loadedSchemas.get( Strings.toLowerCase( schemaName ) );
}
@@ -431,7 +433,7 @@ public class Registries implements Schem
*/
public boolean isSchemaLoaded( String schemaName )
{
- return loadedSchemas.containsKey( Strings.toLowerCase(schemaName) );
+ return loadedSchemas.containsKey( Strings.toLowerCase( schemaName ) );
}
@@ -1004,13 +1006,16 @@ public class Registries implements Schem
catch ( LdapException ne )
{
// This MR's syntax has not been loaded into the Registries.
- errors.add( ne );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.OID_ALREADY_REGISTERED,
+ matchingRule, I18n.err( I18n.ERR_04294, matchingRule.getOid() ) );
+ errors.add( error );
}
}
else
{
// This is an error.
- Throwable error = new LdapProtocolErrorException( I18n.err( I18n.ERR_04294, matchingRule.getOid() ) );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.OID_ALREADY_REGISTERED,
+ matchingRule, I18n.err( I18n.ERR_04294, matchingRule.getOid() ) );
errors.add( error );
}
@@ -1243,7 +1248,9 @@ public class Registries implements Schem
if ( musts.contains( may ) )
{
// This is not allowed.
- Throwable error = new LdapProtocolErrorException( I18n.err( I18n.ERR_04299, objectClass.getOid() ) );
+ Throwable error = new LdapSchemaException(
+ LdapSchemaExceptionCodes.OC_DUPLICATE_AT_IN_MAY_AND_MUST,
+ objectClass, may );
errors.add( error );
return;
}
@@ -1272,7 +1279,9 @@ public class Registries implements Schem
// This OC's superior has not been loaded into the Registries.
if ( !processed.contains( superiorOid ) )
{
- errors.add( ne );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.OC_NONEXISTENT_SUPERIOR,
+ objectClass, superiorOid );
+ errors.add( error );
}
}
@@ -1288,8 +1297,8 @@ public class Registries implements Schem
else
{
// Not allowed : we have a cyle
- Throwable error = new LdapProtocolErrorException( I18n.err( I18n.ERR_04300, objectClass.getOid(),
- superior ) );
+ Throwable error = new LdapSchemaException( LdapSchemaExceptionCodes.OC_CYCLE_CLASS_HIERARCHY,
+ objectClass, superior );
errors.add( error );
return;
}
@@ -1424,7 +1433,7 @@ public class Registries implements Schem
*/
public void schemaLoaded( Schema schema )
{
- this.loadedSchemas.put( Strings.toLowerCase(schema.getSchemaName()), schema );
+ this.loadedSchemas.put( Strings.toLowerCase( schema.getSchemaName() ), schema );
}
@@ -1436,7 +1445,7 @@ public class Registries implements Schem
*/
public void schemaUnloaded( Schema schema )
{
- this.loadedSchemas.remove( Strings.toLowerCase(schema.getSchemaName()) );
+ this.loadedSchemas.remove( Strings.toLowerCase( schema.getSchemaName() ) );
}
@@ -1466,7 +1475,7 @@ public class Registries implements Schem
*/
private String getSchemaName( SchemaObject schemaObject )
{
- String schemaName = Strings.toLowerCase(schemaObject.getSchemaName());
+ String schemaName = Strings.toLowerCase( schemaObject.getSchemaName() );
if ( loadedSchemas.containsKey( schemaName ) )
{
@@ -1632,7 +1641,7 @@ public class Registries implements Schem
if ( content == null )
{
content = new HashSet<SchemaObjectWrapper>();
- schemaObjects.put( Strings.toLowerCase(schemaName), content );
+ schemaObjects.put( Strings.toLowerCase( schemaName ), content );
}
SchemaObjectWrapper schemaObjectWrapper = new SchemaObjectWrapper( schemaObject );
@@ -1740,7 +1749,8 @@ public class Registries implements Schem
* @throws LdapException If the removal failed
*/
// Remove me when TODO is implemented
- @SuppressWarnings({"PMD.UnusedFormalParameter","PMD.EmptyIfStmt"})
+ @SuppressWarnings(
+ { "PMD.UnusedFormalParameter", "PMD.EmptyIfStmt" })
private SchemaObject unregister( List<Throwable> errors, SchemaObject schemaObject ) throws LdapException
{
LOG.debug( "Unregistering {}:{}", schemaObject.getObjectType(), schemaObject.getOid() );
@@ -1825,7 +1835,7 @@ public class Registries implements Schem
public void dissociateFromSchema( SchemaObject schemaObject ) throws LdapException
{
// And unregister the schemaObject within its schema
- Set<SchemaObjectWrapper> content = schemaObjects.get( Strings.toLowerCase(schemaObject.getSchemaName()) );
+ Set<SchemaObjectWrapper> content = schemaObjects.get( Strings.toLowerCase( schemaObject.getSchemaName() ) );
if ( content != null )
{