You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2010/03/16 15:25:51 UTC

svn commit: r923752 - in /directory/apacheds/trunk/jdbm-store/src: main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/MockComparatorRegistry.java

Author: kayyagari
Date: Tue Mar 16 14:25:51 2010
New Revision: 923752

URL: http://svn.apache.org/viewvc?rev=923752&view=rev
Log:
replaced jndi exceptions with ADS specific exceptions

Modified:
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/MockComparatorRegistry.java

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=923752&r1=923751&r2=923752&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Tue Mar 16 14:25:51 2010
@@ -29,8 +29,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import javax.naming.NamingException;
-
 import jdbm.RecordManager;
 import jdbm.helper.MRU;
 import jdbm.recman.BaseRecordManager;
@@ -53,8 +51,10 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.exception.LdapAliasDereferencingException;
+import org.apache.directory.shared.ldap.exception.LdapAliasException;
+import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapNoSuchObjectException;
-import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.AVA;
@@ -674,7 +674,7 @@ public class JdbmStore<E> implements Sto
     /**
      * {@inheritDoc}
      */
-    public void setAliasIndex( Index<String, E, Long> index ) throws NamingException
+    public void setAliasIndex( Index<String, E, Long> index ) throws LdapException
     {
         protect( "aliasIndex" );
         aliasIdx = convertIndex( index );
@@ -694,7 +694,7 @@ public class JdbmStore<E> implements Sto
     /**
      * {@inheritDoc}
      */
-    public void setOneAliasIndex( Index<Long, E, Long> index ) throws NamingException
+    public void setOneAliasIndex( Index<Long, E, Long> index ) throws LdapException
     {
         protect( "oneAliasIndex" );
         oneAliasIdx = convertIndex( index );
@@ -714,7 +714,7 @@ public class JdbmStore<E> implements Sto
     /**
      * {@inheritDoc}
      */
-    public void setSubAliasIndex( Index<Long, E, Long> index ) throws NamingException
+    public void setSubAliasIndex( Index<Long, E, Long> index ) throws LdapException
     {
         protect( "subAliasIndex" );
         subAliasIdx = convertIndex( index );
@@ -734,7 +734,7 @@ public class JdbmStore<E> implements Sto
     /**
      * {@inheritDoc}
      */
-    public void setUpdnIndex( Index<String, E, Long> index ) throws NamingException
+    public void setUpdnIndex( Index<String, E, Long> index ) throws LdapException
     {
         protect( "updnIndex" );
         updnIdx = convertIndex( index );
@@ -754,7 +754,7 @@ public class JdbmStore<E> implements Sto
     /**
      * {@inheritDoc}
      */
-    public void setNdnIndex( Index<String, E, Long> index ) throws NamingException
+    public void setNdnIndex( Index<String, E, Long> index ) throws LdapException
     {
         protect( "ndnIndex" );
         ndnIdx = convertIndex( index );
@@ -774,7 +774,7 @@ public class JdbmStore<E> implements Sto
     /**
      * {@inheritDoc}
      */
-    public void setSubLevelIndex( Index<Long, E, Long> index ) throws NamingException
+    public void setSubLevelIndex( Index<Long, E, Long> index ) throws LdapException
     {
         protect( "subLevelIndex" );
         subLevelIdx = convertIndex( index );
@@ -794,7 +794,7 @@ public class JdbmStore<E> implements Sto
     /**
      * {@inheritDoc}
      */
-    public void setObjectClassIndex( Index<String, E, Long> index ) throws NamingException
+    public void setObjectClassIndex( Index<String, E, Long> index ) throws LdapException
     {
         protect( "objectClassIndex" );
         objectClassIdx = convertIndex( index );
@@ -814,7 +814,7 @@ public class JdbmStore<E> implements Sto
     /**
      * {@inheritDoc}
      */
-    public void setEntryUuidIndex( Index<String, E, Long> index ) throws NamingException
+    public void setEntryUuidIndex( Index<String, E, Long> index ) throws LdapException
     {
         protect( "entryUuidIndex" );
         entryUuidIdx = convertIndex( index );
@@ -834,7 +834,7 @@ public class JdbmStore<E> implements Sto
     /**
      * {@inheritDoc}
      */
-    public void setEntryCsnIndex( Index<String, E, Long> index ) throws NamingException
+    public void setEntryCsnIndex( Index<String, E, Long> index ) throws LdapException
     {
         protect( "entryCsnIndex" );
         entryCsnIdx = convertIndex( index );
@@ -854,19 +854,19 @@ public class JdbmStore<E> implements Sto
     }
 
 
-    public boolean hasIndexOn( String id ) throws NamingException
+    public boolean hasIndexOn( String id ) throws LdapException
     {
         return hasUserIndexOn( id ) || hasSystemIndexOn( id );
     }
 
 
-    public boolean hasUserIndexOn( String id ) throws NamingException
+    public boolean hasUserIndexOn( String id ) throws LdapException
     {
         return userIndices.containsKey( schemaManager.getAttributeTypeRegistry().getOidByName( id ) );
     }
 
 
-    public boolean hasSystemIndexOn( String id ) throws NamingException
+    public boolean hasSystemIndexOn( String id ) throws LdapException
     {
         return systemIndices.containsKey( schemaManager.getAttributeTypeRegistry().getOidByName( id ) );
     }
@@ -878,7 +878,7 @@ public class JdbmStore<E> implements Sto
         {
             id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
         }
-        catch ( NamingException e )
+        catch ( LdapException e )
         {
             String msg = I18n.err( I18n.ERR_128, id );
             LOG.error( msg, e );
@@ -904,7 +904,7 @@ public class JdbmStore<E> implements Sto
         {
             id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
         }
-        catch ( NamingException e )
+        catch ( LdapException e )
         {
             String msg = I18n.err( I18n.ERR_128, id );
             LOG.error( msg, e );
@@ -926,7 +926,7 @@ public class JdbmStore<E> implements Sto
         {
             id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
         }
-        catch ( NamingException e )
+        catch ( LdapException e )
         {
             String msg = I18n.err( I18n.ERR_128, id );
             LOG.error( msg, e );
@@ -1002,7 +1002,7 @@ public class JdbmStore<E> implements Sto
      * 
      * @todo Optimize this by walking the hierarchy index instead of the name 
      * @param aliasId the id of the alias entry in the master table
-     * @throws NamingException if we cannot parse ldap names
+     * @throws LdapException if we cannot parse ldap names
      * @throws Exception if we cannot delete index values in the database
      */
     private void dropAliasIndices( Long aliasId ) throws Exception
@@ -1050,7 +1050,7 @@ public class JdbmStore<E> implements Sto
      * @param aliasDn normalized distinguished name for the alias entry
      * @param aliasTarget the user provided aliased entry dn as a string
      * @param aliasId the id of alias entry to add
-     * @throws NamingException if index addition fails, and if the alias is
+     * @throws LdapException if index addition fails, and if the alias is
      * not allowed due to chaining or cycle formation.
      * @throws Exception if the wrappedCursor btrees cannot be altered
      */
@@ -1080,16 +1080,14 @@ public class JdbmStore<E> implements Sto
             if ( aliasDn.equals( normalizedAliasTargetDn ) )
             {
                 String msg = I18n.err( I18n.ERR_223 );
-                ResultCodeEnum rc = ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM;
-                LdapNamingException e = new LdapNamingException( msg, rc );
-                e.setResolvedName( aliasDn );
+                LdapAliasDereferencingException e = new LdapAliasDereferencingException( msg );
+                //e.setResolvedName( aliasDn );
                 throw e;
             }
 
             String msg = I18n.err( I18n.ERR_224, aliasTarget, aliasDn );
-            ResultCodeEnum rc = ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM;
-            LdapNamingException e = new LdapNamingException( msg, rc );
-            e.setResolvedName( aliasDn );
+            LdapAliasDereferencingException e = new LdapAliasDereferencingException( msg );
+            //e.setResolvedName( aliasDn );
             throw e;
         }
 
@@ -1104,9 +1102,8 @@ public class JdbmStore<E> implements Sto
         if ( !normalizedAliasTargetDn.startsWith( normSuffix ) )
         {
             String msg = I18n.err( I18n.ERR_225, upSuffix.getName() );
-            ResultCodeEnum rc = ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM;
-            LdapNamingException e = new LdapNamingException( msg, rc );
-            e.setResolvedName( aliasDn );
+            LdapAliasDereferencingException e = new LdapAliasDereferencingException( msg );
+            //e.setResolvedName( aliasDn );
             throw e;
         }
 
@@ -1123,9 +1120,8 @@ public class JdbmStore<E> implements Sto
         {
             // Complain about target not existing
             String msg = I18n.err( I18n.ERR_581, aliasDn.getName(), aliasTarget );
-            ResultCodeEnum rc = ResultCodeEnum.ALIAS_PROBLEM;
-            LdapNamingException e = new LdapNamingException( msg, rc );
-            e.setResolvedName( aliasDn );
+            LdapAliasException e = new LdapAliasException( msg );
+            //e.setResolvedName( aliasDn );
             throw e;
         }
 
@@ -1142,9 +1138,8 @@ public class JdbmStore<E> implements Sto
         if ( null != aliasIdx.reverseLookup( targetId ) )
         {
             String msg = I18n.err( I18n.ERR_227 );
-            ResultCodeEnum rc = ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM;
-            LdapNamingException e = new LdapNamingException( msg, rc );
-            e.setResolvedName( aliasDn );
+            LdapAliasDereferencingException e = new LdapAliasDereferencingException( msg );
+            //e.setResolvedName( aliasDn );
             throw e;
         }
 
@@ -1241,8 +1236,8 @@ public class JdbmStore<E> implements Sto
         {
             String msg = I18n.err( I18n.ERR_217, entryDn.getName(), entry );
             ResultCodeEnum rc = ResultCodeEnum.OBJECT_CLASS_VIOLATION;
-            NamingException e = new LdapSchemaViolationException( msg, rc );
-            e.setResolvedName( entryDn );
+            LdapSchemaViolationException e = new LdapSchemaViolationException( rc, msg );
+            //e.setResolvedName( entryDn );
             throw e;
         }
 
@@ -1275,7 +1270,7 @@ public class JdbmStore<E> implements Sto
         if ( entryCsn == null )
         {
             String msg = I18n.err( I18n.ERR_219, entryDn.getName(), entry );
-            throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
+            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, msg );
         }
 
         entryCsnIdx.add( entryCsn.getString(), id );
@@ -1286,7 +1281,7 @@ public class JdbmStore<E> implements Sto
         if ( entryUuid == null )
         {
             String msg = I18n.err( I18n.ERR_220, entryDn.getName(), entry );
-            throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
+            throw new LdapSchemaViolationException( ResultCodeEnum.OBJECT_CLASS_VIOLATION, msg );
         }
 
         entryUuidIdx.add( entryUuid.getString(), id );
@@ -1724,7 +1719,7 @@ public class JdbmStore<E> implements Sto
                     break;
 
                 default:
-                    throw new NamingException( I18n.err( I18n.ERR_221 ) );
+                    throw new LdapException( I18n.err( I18n.ERR_221 ) );
             }
         }
 
@@ -1761,7 +1756,7 @@ public class JdbmStore<E> implements Sto
                     break;
 
                 default:
-                    throw new NamingException( I18n.err( I18n.ERR_221 ) );
+                    throw new LdapException( I18n.err( I18n.ERR_221 ) );
             }
         }
 
@@ -1932,7 +1927,7 @@ public class JdbmStore<E> implements Sto
      * @param updn User provided distinguished name to set as the new DN
      * @param isMove whether or not the name change is due to a move operation
      * which affects alias userIndices.
-     * @throws NamingException if something goes wrong
+     * @throws Exception if something goes wrong
      */
     private void modifyDn( Long id, DN updn, boolean isMove ) throws Exception
     {
@@ -2052,7 +2047,7 @@ public class JdbmStore<E> implements Sto
      * @param oldChildDn the normalized dn of the child to be moved
      * @param childId the id of the child being moved
      * @param newParentDn the normalized dn of the new parent for the child
-     * @throws NamingException if something goes wrong
+     * @throws Exception if something goes wrong
      */
     private DN move( DN oldChildDn, Long childId, DN newParentDn ) throws Exception
     {
@@ -2164,7 +2159,7 @@ public class JdbmStore<E> implements Sto
      * that will no longer be ancestors after the move.
      * 
      * @param movedBase the base at which the move occured - the moved node
-     * @throws NamingException if system userIndices fail
+     * @throws Exception if system userIndices fail
      */
     private void dropMovedAliasIndices( final DN movedBase ) throws Exception
     {

Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/MockComparatorRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/MockComparatorRegistry.java?rev=923752&r1=923751&r2=923752&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/MockComparatorRegistry.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/MockComparatorRegistry.java Tue Mar 16 14:25:51 2010
@@ -24,6 +24,7 @@ import java.util.Iterator;
 
 import javax.naming.NamingException;
 
+import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.schema.LdapComparator;
 import org.apache.directory.shared.ldap.schema.parsers.LdapComparatorDescription;
 import org.apache.directory.shared.ldap.schema.registries.DefaultComparatorRegistry;
@@ -54,7 +55,7 @@ class MockComparatorRegistry extends Def
     };
 
     
-    public String getSchemaName( String oid ) throws NamingException
+    public String getSchemaName( String oid ) throws LdapException
     {
         return null;
     }
@@ -65,13 +66,13 @@ class MockComparatorRegistry extends Def
     }
 
 
-    public LdapComparator<?> lookup( String oid ) throws NamingException
+    public LdapComparator<?> lookup( String oid ) throws LdapException
     {
         return comparator;
     }
 
 
-    public void register(LdapComparator<?> comparator ) throws NamingException
+    public void register(LdapComparator<?> comparator ) throws LdapException
     {
     }
 
@@ -100,7 +101,7 @@ class MockComparatorRegistry extends Def
     }
 
 
-    public LdapComparator<Integer> unregister( String oid ) throws NamingException
+    public LdapComparator<Integer> unregister( String oid ) throws LdapException
     {
 		return this.comparator;
     }