You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/07/23 18:42:32 UTC
svn commit: r679125 -
/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
Author: elecharny
Date: Wed Jul 23 09:42:31 2008
New Revision: 679125
URL: http://svn.apache.org/viewvc?rev=679125&view=rev
Log:
Correctly fixed the check for RDN AVAs having to be seen in entry (dealing with multi-AVA RDN)
Modified:
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=679125&r1=679124&r2=679125&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Wed Jul 23 09:42:31 2008
@@ -386,7 +386,8 @@
}
- public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws Exception
+ public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext )
+ throws Exception
{
EntryFilteringCursor cursor = nextInterceptor.list( opContext );
cursor.addEntryFilter( binaryAttributeFilter );
@@ -659,7 +660,7 @@
}
- public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext )
+ public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext )
throws Exception
{
LdapDN base = opContext.getDn();
@@ -694,7 +695,7 @@
{
cursor.addEntryFilter( ef );
}
-
+
return cursor;
}
@@ -758,8 +759,8 @@
// call.setBypass( true );
ServerEntry serverEntry = schemaService.getSubschemaEntry( searchCtls.getReturningAttributes() );
serverEntry.setDn( base );
- EntryFilteringCursor cursor = new BaseEntryFilteringCursor(
- new SingletonCursor<ServerEntry>( serverEntry ), opContext );
+ EntryFilteringCursor cursor = new BaseEntryFilteringCursor( new SingletonCursor<ServerEntry>(
+ serverEntry ), opContext );
return cursor;
}
}
@@ -1158,12 +1159,12 @@
tmpEntry.add( new DefaultServerAttribute( type, value ) );
}
}
-
+
// Substitute the RDN and check if the new entry is correct
- LdapDN newDn = (LdapDN)name.clone();
+ LdapDN newDn = ( LdapDN ) name.clone();
newDn.remove( name.size() - 1 );
newDn.add( newRdn );
-
+
tmpEntry.setDn( newDn );
check( name, tmpEntry );
@@ -1171,7 +1172,7 @@
for ( AttributeTypeAndValue atav : oldRDN )
{
AttributeType attributeType = atRegistry.lookup( atav.getUpType() );
-
+
if ( !attributeType.isCanUserModify() )
{
throw new NoPermissionException( "Cannot modify the attribute '" + atav.getUpType() + "'" );
@@ -1181,8 +1182,7 @@
if ( name.startsWith( schemaBaseDN ) )
{
- schemaManager.modifyRn( opContext, entry, opContext
- .hasRequestControl( CascadeControl.CONTROL_OID ) );
+ schemaManager.modifyRn( opContext, entry, opContext.hasRequestControl( CascadeControl.CONTROL_OID ) );
}
next.rename( opContext );
@@ -1492,7 +1492,7 @@
next.modify( opContext );
}
-
+
/**
* Filter the attributes by removing the ones which are not allowed
*/
@@ -1502,14 +1502,14 @@
{
return;
}
-
- for ( AttributeTypeOptions attrOptions:operation.getReturningAttributes() )
+
+ for ( AttributeTypeOptions attrOptions : operation.getReturningAttributes() )
{
EntryAttribute attribute = result.get( attrOptions.getAttributeType() );
-
+
if ( attrOptions.hasOption() )
{
- for ( String option:attrOptions.getOptions() )
+ for ( String option : attrOptions.getOptions() )
{
if ( "binary".equalsIgnoreCase( option ) )
{
@@ -1531,12 +1531,12 @@
break;
}
}
-
-
+
}
}
}
+
private void filterObjectClass( ServerEntry entry ) throws Exception
{
List<ObjectClass> objectClasses = new ArrayList<ObjectClass>();
@@ -1605,8 +1605,7 @@
*/
private class BinaryAttributeFilter implements EntryFilter
{
- public boolean accept( SearchingOperationContext operation, ClonedServerEntry result )
- throws Exception
+ public boolean accept( SearchingOperationContext operation, ClonedServerEntry result ) throws Exception
{
filterBinaryAttributes( result );
return true;
@@ -1618,8 +1617,7 @@
*/
private class TopFilter implements EntryFilter
{
- public boolean accept( SearchingOperationContext operation, ClonedServerEntry result )
- throws Exception
+ public boolean accept( SearchingOperationContext operation, ClonedServerEntry result ) throws Exception
{
filterObjectClass( result );
filterAttributeTypes( operation, result );
@@ -1693,29 +1691,25 @@
// Now check the syntaxes
assertSyntaxes( entry );
-
+
// Last, check that the RDN's values are attributes in the entry
Rdn rdn = entry.getDn().getRdn();
-
- if ( rdn.getNbAtavs() == 1 )
+
+ // Loop on all the AVAs
+ for ( AttributeTypeAndValue ava : rdn )
{
- // We have only one AVA
- AttributeTypeAndValue ava = rdn.getAtav();
- String value = (String)ava.getNormValue();
- String upId = ava.getUpType();
-
- if ( !entry.contains( upId, value ) )
- {
- String message = "The RDN '" + upId + "=" + value + "' is not present in the entry";
- LOG.error( message );
+ String value = ( String ) ava.getNormValue();
+ String upId = ava.getUpType();
+
+ // Check that the entry contains this AVA
+ if ( !entry.contains( upId, value ) )
+ {
+ String message = "The RDN '" + upId + "=" + value + "' is not present in the entry";
+ LOG.error( message );
throw new LdapInvalidAttributeValueException( message, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
- }
- }
- else
- {
- // TODO deal with multi AVAs
+ }
}
- }
+ }
/**
@@ -1791,8 +1785,7 @@
/**
* Checks to see number of values of an attribute conforms to the schema
*/
- private void assertNumberOfAttributeValuesValid( Entry entry ) throws InvalidAttributeValueException,
- Exception
+ private void assertNumberOfAttributeValuesValid( Entry entry ) throws InvalidAttributeValueException, Exception
{
for ( EntryAttribute attribute : entry )
{