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/02/14 02:48:55 UTC
svn commit: r507352 - in /directory/apacheds/branches/1.0:
core-unit/src/test/java/org/apache/directory/server/core/jndi/
core/src/main/java/org/apache/directory/server/core/schema/
Author: akarasulu
Date: Tue Feb 13 17:48:55 2007
New Revision: 507352
URL: http://svn.apache.org/viewvc?view=rev&rev=507352
Log:
making sure unknown attributeTypes are handled with the correct exception type
Modified:
directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java
directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/GlobalOidRegistry.java
directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
Modified: directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java?view=diff&rev=507352&r1=507351&r2=507352
==============================================================================
--- directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java (original)
+++ directory/apacheds/branches/1.0/core-unit/src/test/java/org/apache/directory/server/core/jndi/SearchITest.java Tue Feb 13 17:48:55 2007
@@ -31,6 +31,7 @@
import javax.naming.directory.SearchResult;
import org.apache.directory.server.core.unit.AbstractAdminTestCase;
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeIdentifierException;
import org.apache.directory.shared.ldap.message.LockableAttributeImpl;
import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
import org.apache.directory.shared.ldap.message.DerefAliasesEnum;
@@ -261,26 +262,25 @@
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ "cn", "unknownAttribute" } );
-
- NamingEnumeration result = sysRoot.search( rdn, filter, ctls );
-
- if ( result.hasMore() )
+ NamingEnumeration result = null;
+ try
{
- SearchResult entry = ( SearchResult ) result.next();
- Attributes attrs = entry.getAttributes();
- Attribute cn = attrs.get( "cn" );
-
- assertNotNull( cn );
- assertEquals( "Heather Nova", cn.get().toString() );
+ result = sysRoot.search( rdn, filter, ctls );
+ fail( "should never get here due to an invalid attribute exception" );
}
- else
+ catch ( LdapInvalidAttributeIdentifierException e )
{
- fail( "entry " + rdn + " not found" );
}
-
- result.close();
+ finally
+ {
+ if ( result != null )
+ {
+ result.close();
+ }
+ }
}
+
/**
* Search an entry and fetch an attribute with unknown option
*/
@@ -290,27 +290,22 @@
ctls.setSearchScope( SearchControls.OBJECT_SCOPE );
ctls.setReturningAttributes( new String[]
{ "cn", "sn;unknownOption" } );
-
- NamingEnumeration result = sysRoot.search( rdn, filter, ctls );
-
- if ( result.hasMore() )
+ NamingEnumeration result = null;
+ try
{
- SearchResult entry = ( SearchResult ) result.next();
- Attributes attrs = entry.getAttributes();
- Attribute cn = attrs.get( "cn" );
-
- assertNotNull( cn );
- assertEquals( "Heather Nova", cn.get().toString() );
-
- Attribute sn = attrs.get( "sn" );
- assertNull( sn );
+ result = sysRoot.search( rdn, filter, ctls );
+ fail( "should never get here due to an invalid attribute exception" );
}
- else
+ catch ( LdapInvalidAttributeIdentifierException e )
{
- fail( "entry " + rdn + " not found" );
}
-
- result.close();
+ finally
+ {
+ if ( result != null )
+ {
+ result.close();
+ }
+ }
}
/**
Modified: directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/GlobalOidRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/GlobalOidRegistry.java?view=diff&rev=507352&r1=507351&r2=507352
==============================================================================
--- directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/GlobalOidRegistry.java (original)
+++ directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/GlobalOidRegistry.java Tue Feb 13 17:48:55 2007
@@ -30,6 +30,7 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.schema.bootstrap.BootstrapOidRegistry;
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeIdentifierException;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -173,7 +174,7 @@
}
String msg = "OID for name '" + name + "' was not " + "found within the OID registry";
- NamingException fault = new NamingException( msg );
+ NamingException fault = new LdapInvalidAttributeIdentifierException( msg );
monitor.oidResolutionFailed( name, fault );
throw fault;
}
Modified: directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?view=diff&rev=507352&r1=507351&r2=507352
==============================================================================
--- directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Tue Feb 13 17:48:55 2007
@@ -402,6 +402,11 @@
filteredAttrs.put( oid, attribute );
}
}
+ else
+ {
+ throw new LdapInvalidAttributeIdentifierException(
+ "The attribute " + attribute + " was not recognized as a valid attributeType." );
+ }
}
// If we still have the same attribute number, then we can just get out the method
@@ -424,6 +429,7 @@
searchCtls.setReturningAttributes( newAttributesList );
}
+
/**
*
*/