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 2012/01/24 16:43:21 UTC
svn commit: r1235306 [2/3] - in /directory/apacheds/trunk/interceptors:
changelog/src/main/java/org/apache/directory/server/core/changelog/
changelog/src/test/java/org/apache/directory/server/core/changelog/
collective/src/main/java/org/apache/director...
Modified: directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/AttributesFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/AttributesFactory.java?rev=1235306&r1=1235305&r2=1235306&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/AttributesFactory.java (original)
+++ directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/AttributesFactory.java Tue Jan 24 15:43:19 2012
@@ -17,7 +17,7 @@
* under the License.
*
*/
-package org.apache.directory.server.core.schema;
+package org.apache.directory.server.core.schema;
import java.util.List;
@@ -89,11 +89,11 @@ public class AttributesFactory
{
return getAttributes( ( NameForm ) obj, schema, schemaManager );
}
-
+
throw new IllegalArgumentException( I18n.err( I18n.ERR_698, obj.getClass() ) );
}
-
-
+
+
public Entry getAttributes( Schema schema, SchemaManager schemaManager ) throws LdapException
{
Entry entry = new DefaultEntry( schemaManager );
@@ -102,30 +102,31 @@ public class AttributesFactory
entry.put( SchemaConstants.CN_AT, schema.getSchemaName() );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
-
+
if ( schema.isDisabled() )
{
entry.put( MetaSchemaConstants.M_DISABLED_AT, "TRUE" );
}
-
+
String[] dependencies = schema.getDependencies();
-
+
if ( dependencies != null && dependencies.length > 0 )
{
- Attribute attr = new DefaultAttribute( schemaManager.getAttributeType( MetaSchemaConstants.M_DEPENDENCIES_AT ) );
-
- for ( String dependency:dependencies )
+ Attribute attr = new DefaultAttribute(
+ schemaManager.getAttributeType( MetaSchemaConstants.M_DEPENDENCIES_AT ) );
+
+ for ( String dependency : dependencies )
{
attr.add( dependency );
}
-
+
entry.put( attr );
}
-
+
return entry;
}
-
-
+
+
public Entry getAttributes( SyntaxChecker syntaxChecker, Schema schema, SchemaManager schemaManager )
{
Entry entry = new DefaultEntry( schemaManager );
@@ -135,11 +136,11 @@ public class AttributesFactory
entry.put( MetaSchemaConstants.M_FQCN_AT, syntaxChecker.getClass().getName() );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
-
+
return entry;
}
-
+
public Entry getAttributes( LdapSyntax syntax, Schema schema, SchemaManager schemaManager ) throws LdapException
{
Entry entry = new DefaultEntry( schemaManager );
@@ -149,11 +150,11 @@ public class AttributesFactory
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
injectCommon( syntax, entry, schemaManager );
-
+
return entry;
}
-
+
public Entry getAttributes( String oid, Normalizer normalizer, Schema schema, SchemaManager schemaManager )
{
Entry entry = new DefaultEntry( schemaManager );
@@ -166,8 +167,9 @@ public class AttributesFactory
return entry;
}
-
- public Entry getAttributes( String oid, LdapComparator<? super Object> comparator, Schema schema, SchemaManager schemaManager )
+
+ public Entry getAttributes( String oid, LdapComparator<? super Object> comparator, Schema schema,
+ SchemaManager schemaManager )
{
Entry entry = new DefaultEntry( schemaManager );
@@ -186,7 +188,8 @@ public class AttributesFactory
* @return Attributes
* @throws LdapException
*/
- public Entry getAttributes( MatchingRule matchingRule, Schema schema, SchemaManager schemaManager ) throws LdapException
+ public Entry getAttributes( MatchingRule matchingRule, Schema schema, SchemaManager schemaManager )
+ throws LdapException
{
Entry entry = new DefaultEntry( schemaManager );
@@ -198,7 +201,7 @@ public class AttributesFactory
return entry;
}
-
+
public Entry getAttributes( MatchingRuleUse matchingRuleUse, Schema schema, SchemaManager schemaManager )
{
Entry entry = new DefaultEntry( schemaManager );
@@ -209,7 +212,7 @@ public class AttributesFactory
return entry;
}
-
+
public Entry getAttributes( DITStructureRule dITStructureRule, Schema schema, SchemaManager schemaManager )
{
Entry entry = new DefaultEntry( schemaManager );
@@ -220,7 +223,7 @@ public class AttributesFactory
return entry;
}
-
+
public Entry getAttributes( DITContentRule dITContentRule, Schema schema, SchemaManager schemaManager )
{
Entry entry = new DefaultEntry( schemaManager );
@@ -231,7 +234,7 @@ public class AttributesFactory
return entry;
}
-
+
public Entry getAttributes( NameForm nameForm, Schema schema, SchemaManager schemaManager )
{
Entry entry = new DefaultEntry( schemaManager );
@@ -261,28 +264,29 @@ public class AttributesFactory
* @return Attributes
* @throws LdapException
*/
- public Entry getAttributes( AttributeType attributeType, Schema schema, SchemaManager schemaManager ) throws LdapException
+ public Entry getAttributes( AttributeType attributeType, Schema schema, SchemaManager schemaManager )
+ throws LdapException
{
Entry entry = new DefaultEntry( schemaManager );
entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC );
entry.put( MetaSchemaConstants.M_SYNTAX_AT, attributeType.getSyntaxOid() );
entry.put( MetaSchemaConstants.M_COLLECTIVE_AT, getBoolean( attributeType.isCollective() ) );
- entry.put( MetaSchemaConstants.M_NO_USER_MODIFICATION_AT, getBoolean( ! attributeType.isUserModifiable() ) );
+ entry.put( MetaSchemaConstants.M_NO_USER_MODIFICATION_AT, getBoolean( !attributeType.isUserModifiable() ) );
entry.put( MetaSchemaConstants.M_SINGLE_VALUE_AT, getBoolean( attributeType.isSingleValued() ) );
entry.put( MetaSchemaConstants.M_USAGE_AT, attributeType.getUsage().toString() );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
injectCommon( attributeType, entry, schemaManager );
-
+
String superiorOid = attributeType.getSuperiorOid();
-
+
if ( superiorOid != null )
{
entry.put( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT, superiorOid );
}
-
+
if ( attributeType.getEqualityOid() != null )
{
entry.put( MetaSchemaConstants.M_EQUALITY_AT, attributeType.getEqualityOid() );
@@ -301,7 +305,7 @@ public class AttributesFactory
return entry;
}
-
+
/**
* Creates the attributes of an entry representing an objectClass.
*
@@ -321,7 +325,8 @@ public class AttributesFactory
* @return the attributes of the metaSchema entry representing the objectClass
* @throws LdapException if there are any problems
*/
- public Entry getAttributes( ObjectClass objectClass, Schema schema, SchemaManager schemaManager ) throws LdapException
+ public Entry getAttributes( ObjectClass objectClass, Schema schema, SchemaManager schemaManager )
+ throws LdapException
{
Entry entry = new DefaultEntry( schemaManager );
@@ -329,19 +334,20 @@ public class AttributesFactory
entry.put( MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT, objectClass.getType().toString() );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
-
+
injectCommon( objectClass, entry, schemaManager );
// handle the superior objectClasses
if ( objectClass.getSuperiorOids() != null && objectClass.getSuperiorOids().size() != 0 )
{
- Attribute attr = new DefaultAttribute( schemaManager.getAttributeType( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT ) );
-
- for ( String superior:objectClass.getSuperiorOids() )
+ Attribute attr = new DefaultAttribute(
+ schemaManager.getAttributeType( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT ) );
+
+ for ( String superior : objectClass.getSuperiorOids() )
{
- attr.add( superior );
+ attr.add( superior );
}
-
+
entry.put( attr );
}
@@ -350,65 +356,66 @@ public class AttributesFactory
{
Attribute attr = new DefaultAttribute( schemaManager.getAttributeType( MetaSchemaConstants.M_MUST_AT ) );
- for ( String mustOid :objectClass.getMustAttributeTypeOids() )
+ for ( String mustOid : objectClass.getMustAttributeTypeOids() )
{
attr.add( mustOid );
}
-
+
entry.put( attr );
}
-
+
// add the may list
if ( objectClass.getMayAttributeTypeOids() != null && objectClass.getMayAttributeTypeOids().size() != 0 )
{
Attribute attr = new DefaultAttribute( schemaManager.getAttributeType( MetaSchemaConstants.M_MAY_AT ) );
- for ( String mayOid :objectClass.getMayAttributeTypeOids() )
+ for ( String mayOid : objectClass.getMayAttributeTypeOids() )
{
attr.add( mayOid );
}
-
+
entry.put( attr );
}
-
+
return entry;
}
-
-
- private final void injectCommon( SchemaObject object, Entry entry, SchemaManager schemaManager ) throws LdapException
+
+
+ private final void injectCommon( SchemaObject object, Entry entry, SchemaManager schemaManager )
+ throws LdapException
{
injectNames( object.getNames(), entry, schemaManager );
entry.put( MetaSchemaConstants.M_OBSOLETE_AT, getBoolean( object.isObsolete() ) );
entry.put( MetaSchemaConstants.M_OID_AT, object.getOid() );
-
+
if ( object.getDescription() != null )
{
entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, object.getDescription() );
}
}
-
-
+
+
private final void injectNames( List<String> names, Entry entry, SchemaManager schemaManager ) throws LdapException
{
if ( ( names == null ) || ( names.size() == 0 ) )
{
return;
}
-
+
Attribute attr = new DefaultAttribute( schemaManager.getAttributeType( MetaSchemaConstants.M_NAME_AT ) );
- for ( String name:names )
+ for ( String name : names )
{
attr.add( name );
}
-
+
entry.put( attr );
}
-
+
private final String getBoolean( boolean value )
{
- if ( value )
+ if ( value )
{
return "TRUE";
}
Modified: directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=1235306&r1=1235305&r2=1235306&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original)
+++ directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Tue Jan 24 15:43:19 2012
@@ -156,6 +156,7 @@ public class SchemaInterceptor extends B
/** A map used to store all the objectClasses allowed attributes (may + must) */
private Map<String, List<AttributeType>> allowed;
+
/**
* Creates a new instance of a SchemaInterceptor.
*/
@@ -194,7 +195,8 @@ public class SchemaInterceptor extends B
subschemaSubentryDn.apply( schemaManager );
subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();
- schemaModificationAttributesDn = directoryService.getDnFactory().create( SchemaConstants.SCHEMA_MODIFICATIONS_DN );
+ schemaModificationAttributesDn = directoryService.getDnFactory().create(
+ SchemaConstants.SCHEMA_MODIFICATIONS_DN );
schemaModificationAttributesDn.apply( schemaManager );
computeSuperiors();
@@ -306,7 +308,8 @@ public class SchemaInterceptor extends B
* As a result, we will gather all of these three ObjectClasses in 'inetOrgPerson' ObjectClasse
* superiors.
*/
- private void computeOCSuperiors( ObjectClass objectClass, List<ObjectClass> superiors, Set<String> ocSeen ) throws LdapException
+ private void computeOCSuperiors( ObjectClass objectClass, List<ObjectClass> superiors, Set<String> ocSeen )
+ throws LdapException
{
List<ObjectClass> parents = objectClass.getSuperiors();
@@ -477,7 +480,7 @@ public class SchemaInterceptor extends B
int pos = 0;
- for (Map.Entry<String, String> entry : filteredAttrs.entrySet() )
+ for ( Map.Entry<String, String> entry : filteredAttrs.entrySet() )
{
newAttributesList[pos++] = entry.getValue();
}
@@ -494,7 +497,7 @@ public class SchemaInterceptor extends B
{
try
{
- return new StringValue( attributeType, new String( (( BinaryValue ) value).getBytes(), "UTF-8" ) );
+ return new StringValue( attributeType, new String( ( ( BinaryValue ) value ).getBytes(), "UTF-8" ) );
}
catch ( UnsupportedEncodingException uee )
{
@@ -532,7 +535,7 @@ public class SchemaInterceptor extends B
if ( filter.isLeaf() )
{
- if ( filter instanceof EqualityNode)
+ if ( filter instanceof EqualityNode )
{
EqualityNode node = ( ( EqualityNode ) filter );
Value<?> value = node.getValue();
@@ -553,7 +556,7 @@ public class SchemaInterceptor extends B
}
else if ( filter instanceof GreaterEqNode )
{
- GreaterEqNode node = ( (GreaterEqNode) filter );
+ GreaterEqNode node = ( ( GreaterEqNode ) filter );
Value<?> value = node.getValue();
Value<?> newValue = convert( node.getAttributeType(), value );
@@ -576,13 +579,13 @@ public class SchemaInterceptor extends B
node.setValue( newValue );
}
}
- else if ( filter instanceof ExtensibleNode)
+ else if ( filter instanceof ExtensibleNode )
{
ExtensibleNode node = ( ( ExtensibleNode ) filter );
}
else if ( filter instanceof ApproximateNode )
{
- ApproximateNode node = ( (ApproximateNode) filter );
+ ApproximateNode node = ( ( ApproximateNode ) filter );
Value<?> value = node.getValue();
Value<?> newValue = convert( node.getAttributeType(), value );
@@ -1071,7 +1074,6 @@ public class SchemaInterceptor extends B
}
}
-
/**
* Filters objectClass attribute to inject top when not present.
*/
@@ -1233,7 +1235,7 @@ public class SchemaInterceptor extends B
check( name, entry );
// Special checks for the MetaSchema branch
- if ( name.isDescendantOf(schemaBaseDn) )
+ if ( name.isDescendantOf( schemaBaseDn ) )
{
// get the schema name
String schemaName = getSchemaName( name );
@@ -1375,7 +1377,7 @@ public class SchemaInterceptor extends B
}
modifyContext.setModItems( cleanMods );
-
+
// Now that the entry has been modified, update the SSSE
schemaSubEntryManager.modifySchemaSubentry( modifyContext, modifyContext
.hasRequestControl( Cascade.OID ) );
@@ -1399,7 +1401,7 @@ public class SchemaInterceptor extends B
Dn oldDn = renameContext.getDn();
Rdn newRdn = renameContext.getNewRdn();
boolean deleteOldRn = renameContext.getDeleteOldRdn();
- Entry entry = ((ClonedServerEntry)renameContext.getEntry()).getClonedEntry();
+ Entry entry = ( ( ClonedServerEntry ) renameContext.getEntry() ).getClonedEntry();
/*
* Note: This is only a consistency checks, to the ensure that all
@@ -1414,14 +1416,14 @@ public class SchemaInterceptor extends B
// Delete the old Rdn means we remove some attributes and values.
// We must make sure that after this operation all must attributes
// are still present in the entry.
- for ( Ava atav : oldRdn)
+ for ( Ava atav : oldRdn )
{
AttributeType type = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
entry.remove( type, atav.getUpValue() );
}
// Check that no operational attributes are removed
- for ( Ava atav : oldRdn)
+ for ( Ava atav : oldRdn )
{
AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( atav.getUpType() );
@@ -1498,7 +1500,7 @@ public class SchemaInterceptor extends B
if ( searchCtls.getSearchScope() == SearchControls.OBJECT_SCOPE )
{
// The filter can be an equality or a presence, but nothing else
- if ( filter instanceof SimpleNode)
+ if ( filter instanceof SimpleNode )
{
// We should get the value for the filter.
// only 'top' and 'subSchema' are valid values
@@ -1526,7 +1528,8 @@ public class SchemaInterceptor extends B
.equals( SchemaConstants.SUBSCHEMA_OC_OID ) ) && ( node instanceof EqualityNode ) )
{
// call.setBypass( true );
- Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() );
+ Entry serverEntry = SchemaService.getSubschemaEntry( directoryService,
+ searchCtls.getReturningAttributes() );
serverEntry.setDn( base );
return new BaseEntryFilteringCursor( new SingletonCursor<Entry>( serverEntry ), searchContext );
}
@@ -1543,7 +1546,8 @@ public class SchemaInterceptor extends B
if ( node.getAttributeType().equals( OBJECT_CLASS_AT ) )
{
// call.setBypass( true );
- Entry serverEntry = SchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() );
+ Entry serverEntry = SchemaService.getSubschemaEntry( directoryService,
+ searchCtls.getReturningAttributes() );
serverEntry.setDn( base );
EntryFilteringCursor cursor = new BaseEntryFilteringCursor(
new SingletonCursor<Entry>( serverEntry ), searchContext );
@@ -1647,13 +1651,13 @@ public class SchemaInterceptor extends B
StringBuilder sb = new StringBuilder();
sb.append( '[' );
- for( String oid: must )
+ for ( String oid : must )
{
String name = schemaManager.getAttributeType( oid ).getName();
sb.append( name )
- .append( '(' )
- .append( oid )
- .append( "), " );
+ .append( '(' )
+ .append( oid )
+ .append( "), " );
}
int end = sb.length();
@@ -1857,7 +1861,7 @@ public class SchemaInterceptor extends B
{
continue;
}
- else if ( value instanceof StringValue)
+ else if ( value instanceof StringValue )
{
// We have a String value. It should be a byte[]
// Let's transform it
Modified: directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryManager.java?rev=1235306&r1=1235305&r2=1235306&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryManager.java (original)
+++ directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryManager.java Tue Jan 24 15:43:19 2012
@@ -84,22 +84,22 @@ public class SchemaSubentryManager
/** The schemaManager */
private final SchemaManager schemaManager;
-
+
private final SchemaSubentryModifier subentryModifier;
-
+
/** The description parsers */
private final DescriptionParsers parsers;
-
+
/**
* Maps the OID of a subschemaSubentry operational attribute to the index of
* the handler in the schemaObjectHandlers array.
*/
private final Map<String, Integer> opAttr2handlerIndex = new HashMap<String, Integer>( 11 );
private static final String CASCADING_ERROR =
- "Cascading has not yet been implemented: standard operation is in effect.";
+ "Cascading has not yet been implemented: standard operation is in effect.";
private static AttributeType ENTRY_CSN_ATTRIBUTE_TYPE;
-
+
static
{
VALID_OU_VALUES.add( Strings.toLowerCase( SchemaConstants.NORMALIZERS_AT ) );
@@ -122,44 +122,52 @@ public class SchemaSubentryManager
this.schemaManager = schemaManager;
this.subentryModifier = new SchemaSubentryModifier( schemaManager, dnFactory );
this.parsers = new DescriptionParsers( schemaManager );
-
+
String comparatorsOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.COMPARATORS_AT );
opAttr2handlerIndex.put( comparatorsOid, COMPARATOR_INDEX );
String normalizersOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.NORMALIZERS_AT );
opAttr2handlerIndex.put( normalizersOid, NORMALIZER_INDEX );
- String syntaxCheckersOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.SYNTAX_CHECKERS_AT );
+ String syntaxCheckersOid = schemaManager.getAttributeTypeRegistry().getOidByName(
+ SchemaConstants.SYNTAX_CHECKERS_AT );
opAttr2handlerIndex.put( syntaxCheckersOid, SYNTAX_CHECKER_INDEX );
- String ldapSyntaxesOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.LDAP_SYNTAXES_AT );
+ String ldapSyntaxesOid = schemaManager.getAttributeTypeRegistry().getOidByName(
+ SchemaConstants.LDAP_SYNTAXES_AT );
opAttr2handlerIndex.put( ldapSyntaxesOid, SYNTAX_INDEX );
- String matchingRulesOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.MATCHING_RULES_AT );
+ String matchingRulesOid = schemaManager.getAttributeTypeRegistry().getOidByName(
+ SchemaConstants.MATCHING_RULES_AT );
opAttr2handlerIndex.put( matchingRulesOid, MATCHING_RULE_INDEX );
- String attributeTypesOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.ATTRIBUTE_TYPES_AT );
+ String attributeTypesOid = schemaManager.getAttributeTypeRegistry().getOidByName(
+ SchemaConstants.ATTRIBUTE_TYPES_AT );
opAttr2handlerIndex.put( attributeTypesOid, ATTRIBUTE_TYPE_INDEX );
- String objectClassesOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.OBJECT_CLASSES_AT );
+ String objectClassesOid = schemaManager.getAttributeTypeRegistry().getOidByName(
+ SchemaConstants.OBJECT_CLASSES_AT );
opAttr2handlerIndex.put( objectClassesOid, OBJECT_CLASS_INDEX );
- String matchingRuleUseOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.MATCHING_RULE_USE_AT );
+ String matchingRuleUseOid = schemaManager.getAttributeTypeRegistry().getOidByName(
+ SchemaConstants.MATCHING_RULE_USE_AT );
opAttr2handlerIndex.put( matchingRuleUseOid, MATCHING_RULE_USE_INDEX );
- String ditStructureRulesOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.DIT_STRUCTURE_RULES_AT );
+ String ditStructureRulesOid = schemaManager.getAttributeTypeRegistry().getOidByName(
+ SchemaConstants.DIT_STRUCTURE_RULES_AT );
opAttr2handlerIndex.put( ditStructureRulesOid, DIT_STRUCTURE_RULE_INDEX );
- String ditContentRulesOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.DIT_CONTENT_RULES_AT );
+ String ditContentRulesOid = schemaManager.getAttributeTypeRegistry().getOidByName(
+ SchemaConstants.DIT_CONTENT_RULES_AT );
opAttr2handlerIndex.put( ditContentRulesOid, DIT_CONTENT_RULE_INDEX );
String nameFormsOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.NAME_FORMS_AT );
opAttr2handlerIndex.put( nameFormsOid, NAME_FORM_INDEX );
-
+
ENTRY_CSN_ATTRIBUTE_TYPE = schemaManager.getAttributeType( SchemaConstants.ENTRY_CSN_AT );
}
-
+
/**
* Find the next interceptor in an operation's list of interceptors, assuming that
* we are already processing an operation, and we have stopped in a specific
@@ -174,72 +182,73 @@ public class SchemaSubentryManager
private Interceptor findNextInterceptor( OperationEnum operation, DirectoryService directoryService )
{
Interceptor interceptor = null;
-
+
List<Interceptor> allInterceptors = directoryService.getInterceptors();
List<String> operationInterceptors = directoryService.getInterceptors( operation );
int position = 0;
String addInterceptor = operationInterceptors.get( position );
-
+
for ( Interceptor inter : allInterceptors )
{
String interName = inter.getName();
-
+
if ( interName.equals( InterceptorEnum.SCHEMA_INTERCEPTOR.getName() ) )
{
// Found, get out
position++;
-
+
if ( position < operationInterceptors.size() )
{
interceptor = directoryService.getInterceptor( operationInterceptors.get( position ) );
}
-
+
break;
}
-
+
if ( interName.equals( addInterceptor ) )
{
position++;
addInterceptor = operationInterceptors.get( position );
}
}
-
+
return interceptor;
}
-
-
+
+
/**
* Find the position in the operation's list knowing the inteceptor name.
*/
private int findPosition( OperationEnum operation, Interceptor interceptor, DirectoryService directoryService )
{
int position = 1;
-
+
List<String> interceptors = directoryService.getInterceptors( operation );
-
+
String interceptorName = interceptor.getName();
-
+
for ( String name : interceptors )
{
if ( name.equals( interceptorName ) )
{
break;
}
-
+
position++;
}
-
+
return position;
}
-
-
+
+
/**
* Update the SubschemaSubentry with all the modifications
*/
- public void modifySchemaSubentry( ModifyOperationContext modifyContext, boolean doCascadeModify ) throws LdapException
+ public void modifySchemaSubentry( ModifyOperationContext modifyContext, boolean doCascadeModify )
+ throws LdapException
{
DirectoryService directoryService = modifyContext.getSession().getDirectoryService();
-
+
// Compute the next interceptor for the Add and Delete operation, starting from
// the schemaInterceptor. We also need to get the position of this next interceptor
// in the operation's list.
@@ -251,20 +260,21 @@ public class SchemaSubentryManager
for ( Modification mod : modifyContext.getModItems() )
{
String opAttrOid = schemaManager.getAttributeTypeRegistry().getOidByName( mod.getAttribute().getId() );
-
+
Attribute serverAttribute = mod.getAttribute();
switch ( mod.getOperation() )
{
- case ADD_ATTRIBUTE :
- modifyAddOperation( nextAdd, positionAdd, modifyContext, opAttrOid, serverAttribute, doCascadeModify );
+ case ADD_ATTRIBUTE:
+ modifyAddOperation( nextAdd, positionAdd, modifyContext, opAttrOid, serverAttribute,
+ doCascadeModify );
break;
-
- case REMOVE_ATTRIBUTE :
+
+ case REMOVE_ATTRIBUTE:
modifyRemoveOperation( nextDelete, positionDelete, modifyContext, opAttrOid, serverAttribute );
break;
-
- case REPLACE_ATTRIBUTE :
+
+ case REPLACE_ATTRIBUTE:
// a hack to allow entryCSN modification
if ( ENTRY_CSN_ATTRIBUTE_TYPE.equals( serverAttribute.getAttributeType() ) )
{
@@ -273,14 +283,14 @@ public class SchemaSubentryManager
throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM,
I18n.err( I18n.ERR_283 ) );
-
+
default:
throw new IllegalStateException( I18n.err( I18n.ERR_284, mod.getOperation() ) );
}
}
}
-
-
+
+
/**
* Handles the modify remove operation on the subschemaSubentry for schema entities.
*
@@ -290,129 +300,130 @@ public class SchemaSubentryManager
* @throws Exception if there are problems updating the registries and the
* schema partition
*/
- private void modifyRemoveOperation( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext, String opAttrOid,
+ private void modifyRemoveOperation( Interceptor nextInterceptor, int position,
+ ModifyOperationContext modifyContext, String opAttrOid,
Attribute mods ) throws LdapException
{
int index = opAttr2handlerIndex.get( opAttrOid );
-
- switch( index )
+
+ switch ( index )
{
- case( COMPARATOR_INDEX ):
+ case ( COMPARATOR_INDEX ):
LdapComparatorDescription[] comparatorDescriptions = parsers.parseComparators( mods );
-
+
for ( LdapComparatorDescription comparatorDescription : comparatorDescriptions )
{
subentryModifier.delete( nextInterceptor, position, modifyContext, comparatorDescription );
}
-
+
break;
-
- case( NORMALIZER_INDEX ):
+
+ case ( NORMALIZER_INDEX ):
NormalizerDescription[] normalizerDescriptions = parsers.parseNormalizers( mods );
-
+
for ( NormalizerDescription normalizerDescription : normalizerDescriptions )
{
subentryModifier.delete( nextInterceptor, position, modifyContext, normalizerDescription );
}
-
+
break;
-
- case( SYNTAX_CHECKER_INDEX ):
+
+ case ( SYNTAX_CHECKER_INDEX ):
SyntaxCheckerDescription[] syntaxCheckerDescriptions = parsers.parseSyntaxCheckers( mods );
-
+
for ( SyntaxCheckerDescription syntaxCheckerDescription : syntaxCheckerDescriptions )
{
subentryModifier.delete( nextInterceptor, position, modifyContext, syntaxCheckerDescription );
}
-
+
break;
-
- case( SYNTAX_INDEX ):
+
+ case ( SYNTAX_INDEX ):
LdapSyntax[] syntaxes = parsers.parseLdapSyntaxes( mods );
-
+
for ( LdapSyntax syntax : syntaxes )
{
subentryModifier.deleteSchemaObject( nextInterceptor, position, modifyContext, syntax );
}
-
+
break;
-
- case( MATCHING_RULE_INDEX ):
+
+ case ( MATCHING_RULE_INDEX ):
MatchingRule[] mrs = parsers.parseMatchingRules( mods );
-
+
for ( MatchingRule mr : mrs )
{
subentryModifier.deleteSchemaObject( nextInterceptor, position, modifyContext, mr );
}
-
+
break;
-
- case( ATTRIBUTE_TYPE_INDEX ):
+
+ case ( ATTRIBUTE_TYPE_INDEX ):
AttributeType[] ats = parsers.parseAttributeTypes( mods );
-
+
for ( AttributeType at : ats )
{
subentryModifier.deleteSchemaObject( nextInterceptor, position, modifyContext, at );
}
-
+
break;
-
- case( OBJECT_CLASS_INDEX ):
+
+ case ( OBJECT_CLASS_INDEX ):
ObjectClass[] ocs = parsers.parseObjectClasses( mods );
for ( ObjectClass oc : ocs )
{
subentryModifier.deleteSchemaObject( nextInterceptor, position, modifyContext, oc );
}
-
+
break;
-
- case( MATCHING_RULE_USE_INDEX ):
+
+ case ( MATCHING_RULE_USE_INDEX ):
MatchingRuleUse[] mrus = parsers.parseMatchingRuleUses( mods );
-
+
for ( MatchingRuleUse mru : mrus )
{
subentryModifier.deleteSchemaObject( nextInterceptor, position, modifyContext, mru );
}
-
+
break;
-
- case( DIT_STRUCTURE_RULE_INDEX ):
+
+ case ( DIT_STRUCTURE_RULE_INDEX ):
DITStructureRule[] dsrs = parsers.parseDitStructureRules( mods );
-
+
for ( DITStructureRule dsr : dsrs )
{
subentryModifier.deleteSchemaObject( nextInterceptor, position, modifyContext, dsr );
}
-
+
break;
-
- case( DIT_CONTENT_RULE_INDEX ):
+
+ case ( DIT_CONTENT_RULE_INDEX ):
DITContentRule[] dcrs = parsers.parseDitContentRules( mods );
-
+
for ( DITContentRule dcr : dcrs )
{
subentryModifier.deleteSchemaObject( nextInterceptor, position, modifyContext, dcr );
}
-
+
break;
-
- case( NAME_FORM_INDEX ):
+
+ case ( NAME_FORM_INDEX ):
NameForm[] nfs = parsers.parseNameForms( mods );
-
+
for ( NameForm nf : nfs )
{
subentryModifier.deleteSchemaObject( nextInterceptor, position, modifyContext, nf );
}
-
+
break;
-
+
default:
throw new IllegalStateException( I18n.err( I18n.ERR_285, index ) );
}
}
-
-
+
+
/**
* Handles the modify add operation on the subschemaSubentry for schema entities.
*
@@ -423,7 +434,8 @@ public class SchemaSubentryManager
* @throws Exception if there are problems updating the registries and the
* schema partition
*/
- private void modifyAddOperation( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext, String opAttrOid,
+ private void modifyAddOperation( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext,
+ String opAttrOid,
Attribute mods, boolean doCascadeModify ) throws LdapException
{
if ( doCascadeModify )
@@ -432,119 +444,119 @@ public class SchemaSubentryManager
}
int index = opAttr2handlerIndex.get( opAttrOid );
-
- switch( index )
+
+ switch ( index )
{
- case( COMPARATOR_INDEX ):
+ case ( COMPARATOR_INDEX ):
LdapComparatorDescription[] comparatorDescriptions = parsers.parseComparators( mods );
-
+
for ( LdapComparatorDescription comparatorDescription : comparatorDescriptions )
{
subentryModifier.add( nextInterceptor, position, modifyContext, comparatorDescription );
}
-
+
break;
-
- case( NORMALIZER_INDEX ):
+
+ case ( NORMALIZER_INDEX ):
NormalizerDescription[] normalizerDescriptions = parsers.parseNormalizers( mods );
-
+
for ( NormalizerDescription normalizerDescription : normalizerDescriptions )
{
subentryModifier.add( nextInterceptor, position, modifyContext, normalizerDescription );
}
-
+
break;
-
- case( SYNTAX_CHECKER_INDEX ):
+
+ case ( SYNTAX_CHECKER_INDEX ):
SyntaxCheckerDescription[] syntaxCheckerDescriptions = parsers.parseSyntaxCheckers( mods );
-
+
for ( SyntaxCheckerDescription syntaxCheckerDescription : syntaxCheckerDescriptions )
{
subentryModifier.add( nextInterceptor, position, modifyContext, syntaxCheckerDescription );
}
-
+
break;
-
- case( SYNTAX_INDEX ):
+
+ case ( SYNTAX_INDEX ):
LdapSyntax[] syntaxes = parsers.parseLdapSyntaxes( mods );
-
+
for ( LdapSyntax syntax : syntaxes )
{
subentryModifier.addSchemaObject( nextInterceptor, position, modifyContext, syntax );
}
-
+
break;
-
- case( MATCHING_RULE_INDEX ):
+
+ case ( MATCHING_RULE_INDEX ):
MatchingRule[] mrs = parsers.parseMatchingRules( mods );
-
+
for ( MatchingRule mr : mrs )
{
subentryModifier.addSchemaObject( nextInterceptor, position, modifyContext, mr );
}
-
+
break;
-
- case( ATTRIBUTE_TYPE_INDEX ):
+
+ case ( ATTRIBUTE_TYPE_INDEX ):
AttributeType[] ats = parsers.parseAttributeTypes( mods );
-
+
for ( AttributeType at : ats )
{
subentryModifier.addSchemaObject( nextInterceptor, position, modifyContext, at );
}
-
+
break;
-
- case( OBJECT_CLASS_INDEX ):
+
+ case ( OBJECT_CLASS_INDEX ):
ObjectClass[] ocs = parsers.parseObjectClasses( mods );
for ( ObjectClass oc : ocs )
{
subentryModifier.addSchemaObject( nextInterceptor, position, modifyContext, oc );
}
-
+
break;
-
- case( MATCHING_RULE_USE_INDEX ):
+
+ case ( MATCHING_RULE_USE_INDEX ):
MatchingRuleUse[] mrus = parsers.parseMatchingRuleUses( mods );
-
+
for ( MatchingRuleUse mru : mrus )
{
subentryModifier.addSchemaObject( nextInterceptor, position, modifyContext, mru );
}
-
+
break;
-
- case( DIT_STRUCTURE_RULE_INDEX ):
+
+ case ( DIT_STRUCTURE_RULE_INDEX ):
DITStructureRule[] dsrs = parsers.parseDitStructureRules( mods );
-
+
for ( DITStructureRule dsr : dsrs )
{
subentryModifier.addSchemaObject( nextInterceptor, position, modifyContext, dsr );
}
-
+
break;
-
- case( DIT_CONTENT_RULE_INDEX ):
+
+ case ( DIT_CONTENT_RULE_INDEX ):
DITContentRule[] dcrs = parsers.parseDitContentRules( mods );
-
+
for ( DITContentRule dcr : dcrs )
{
subentryModifier.addSchemaObject( nextInterceptor, position, modifyContext, dcr );
}
-
+
break;
-
- case( NAME_FORM_INDEX ):
+
+ case ( NAME_FORM_INDEX ):
NameForm[] nfs = parsers.parseNameForms( mods );
-
+
for ( NameForm nf : nfs )
{
subentryModifier.addSchemaObject( nextInterceptor, position, modifyContext, nf );
}
-
+
break;
-
+
default:
throw new IllegalStateException( I18n.err( I18n.ERR_285, index ) );
}
Modified: directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java?rev=1235306&r1=1235305&r2=1235306&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java (original)
+++ directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryModifier.java Tue Jan 24 15:43:19 2012
@@ -78,8 +78,8 @@ public class SchemaSubentryModifier
this.schemaManager = schemaManager;
this.dnFactory = dnFactory;
}
-
-
+
+
private Dn getDn( SchemaObject obj ) throws LdapInvalidDnException
{
StringBuffer buf = new StringBuffer();
@@ -121,9 +121,10 @@ public class SchemaSubentryModifier
buf.append( ",cn=" ).append( obj.getSchemaName() ).append( ",ou=schema" );
return dnFactory.create( buf.toString() );
}
-
- public void add( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext, LdapComparatorDescription comparatorDescription ) throws LdapException
+
+ public void add( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext,
+ LdapComparatorDescription comparatorDescription ) throws LdapException
{
String schemaName = getSchema( comparatorDescription );
Dn dn = dnFactory.create(
@@ -131,7 +132,7 @@ public class SchemaSubentryModifier
SchemaConstants.COMPARATORS_PATH,
"cn=" + schemaName,
SchemaConstants.OU_SCHEMA );
-
+
Entry entry = getEntry( dn, comparatorDescription );
AddOperationContext addContext = new AddOperationContext( modifyContext.getSession(), entry );
@@ -139,17 +140,18 @@ public class SchemaSubentryModifier
nextInterceptor.add( addContext );
}
-
-
- public void add( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext, NormalizerDescription normalizerDescription ) throws LdapException
+
+
+ public void add( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext,
+ NormalizerDescription normalizerDescription ) throws LdapException
{
String schemaName = getSchema( normalizerDescription );
Dn dn = dnFactory.create(
"m-oid=" + normalizerDescription.getOid(),
- SchemaConstants.NORMALIZERS_PATH ,
+ SchemaConstants.NORMALIZERS_PATH,
"cn=" + schemaName,
SchemaConstants.OU_SCHEMA );
-
+
Entry entry = getEntry( dn, normalizerDescription );
AddOperationContext addContext = new AddOperationContext( modifyContext.getSession(), entry );
@@ -157,9 +159,10 @@ public class SchemaSubentryModifier
nextInterceptor.add( addContext );
}
-
-
- public void add( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext, SyntaxCheckerDescription syntaxCheckerDescription ) throws LdapException
+
+
+ public void add( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext,
+ SyntaxCheckerDescription syntaxCheckerDescription ) throws LdapException
{
String schemaName = getSchema( syntaxCheckerDescription );
Dn dn = dnFactory.create(
@@ -167,7 +170,7 @@ public class SchemaSubentryModifier
SchemaConstants.SYNTAX_CHECKERS_PATH,
"cn=" + schemaName,
SchemaConstants.OU_SCHEMA );
-
+
Entry entry = getEntry( dn, syntaxCheckerDescription );
AddOperationContext addContext = new AddOperationContext( modifyContext.getSession(), entry );
@@ -175,15 +178,16 @@ public class SchemaSubentryModifier
nextInterceptor.add( addContext );
}
-
-
- public void addSchemaObject( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext, SchemaObject obj ) throws LdapException
+
+
+ public void addSchemaObject( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext,
+ SchemaObject obj ) throws LdapException
{
Schema schema = schemaManager.getLoadedSchema( obj.getSchemaName() );
Dn dn = getDn( obj );
Entry entry = factory.getAttributes( obj, schema, schemaManager );
entry.setDn( dn );
-
+
AddOperationContext addContext = new AddOperationContext( modifyContext.getSession(), entry );
addContext.setCurrentInterceptor( position );
@@ -191,7 +195,8 @@ public class SchemaSubentryModifier
}
- public void deleteSchemaObject( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext, SchemaObject obj ) throws LdapException
+ public void deleteSchemaObject( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext,
+ SchemaObject obj ) throws LdapException
{
Dn dn = getDn( obj );
@@ -202,8 +207,9 @@ public class SchemaSubentryModifier
nextInterceptor.delete( deleteContext );
}
-
- public void delete( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext, NormalizerDescription normalizerDescription ) throws LdapException
+
+ public void delete( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext,
+ NormalizerDescription normalizerDescription ) throws LdapException
{
String schemaName = getSchema( normalizerDescription );
Dn dn = dnFactory.create(
@@ -211,7 +217,7 @@ public class SchemaSubentryModifier
SchemaConstants.NORMALIZERS_PATH,
"cn=" + schemaName,
SchemaConstants.OU_SCHEMA );
-
+
DeleteOperationContext deleteContext = new DeleteOperationContext( modifyContext.getSession(), dn );
deleteContext.setEntry( modifyContext.getSession().lookup( dn ) );
deleteContext.setCurrentInterceptor( position );
@@ -220,7 +226,8 @@ public class SchemaSubentryModifier
}
- public void delete( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext, SyntaxCheckerDescription syntaxCheckerDescription ) throws LdapException
+ public void delete( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext,
+ SyntaxCheckerDescription syntaxCheckerDescription ) throws LdapException
{
String schemaName = getSchema( syntaxCheckerDescription );
Dn dn = dnFactory.create(
@@ -237,7 +244,8 @@ public class SchemaSubentryModifier
}
- public void delete( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext, LdapComparatorDescription comparatorDescription ) throws LdapException
+ public void delete( Interceptor nextInterceptor, int position, ModifyOperationContext modifyContext,
+ LdapComparatorDescription comparatorDescription ) throws LdapException
{
String schemaName = getSchema( comparatorDescription );
Dn dn = dnFactory.create(
@@ -245,7 +253,7 @@ public class SchemaSubentryModifier
SchemaConstants.COMPARATORS_PATH,
"cn=" + schemaName,
SchemaConstants.OU_SCHEMA );
-
+
DeleteOperationContext deleteContext = new DeleteOperationContext( modifyContext.getSession(), dn );
deleteContext.setEntry( modifyContext.getSession().lookup( dn ) );
deleteContext.setCurrentInterceptor( position );
@@ -257,12 +265,12 @@ public class SchemaSubentryModifier
private Entry getEntry( Dn dn, LdapComparatorDescription comparatorDescription )
{
Entry entry = new DefaultEntry( schemaManager, dn );
-
+
entry.put( SchemaConstants.OBJECT_CLASS_AT,
- SchemaConstants.TOP_OC,
- MetaSchemaConstants.META_TOP_OC,
- MetaSchemaConstants.META_COMPARATOR_OC );
-
+ SchemaConstants.TOP_OC,
+ MetaSchemaConstants.META_TOP_OC,
+ MetaSchemaConstants.META_COMPARATOR_OC );
+
entry.put( MetaSchemaConstants.M_OID_AT, comparatorDescription.getOid() );
entry.put( MetaSchemaConstants.M_FQCN_AT, comparatorDescription.getFqcn() );
@@ -271,12 +279,12 @@ public class SchemaSubentryModifier
entry.put( MetaSchemaConstants.M_BYTECODE_AT,
Base64.decode( comparatorDescription.getBytecode().toCharArray() ) );
}
-
+
if ( comparatorDescription.getDescription() != null )
{
entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, comparatorDescription.getDescription() );
}
-
+
return entry;
}
@@ -289,7 +297,7 @@ public class SchemaSubentryModifier
SchemaConstants.TOP_OC,
MetaSchemaConstants.META_TOP_OC,
MetaSchemaConstants.META_NORMALIZER_OC );
-
+
entry.put( MetaSchemaConstants.M_OID_AT, normalizerDescription.getOid() );
entry.put( MetaSchemaConstants.M_FQCN_AT, normalizerDescription.getFqcn() );
@@ -298,12 +306,12 @@ public class SchemaSubentryModifier
entry.put( MetaSchemaConstants.M_BYTECODE_AT,
Base64.decode( normalizerDescription.getBytecode().toCharArray() ) );
}
-
+
if ( normalizerDescription.getDescription() != null )
{
entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, normalizerDescription.getDescription() );
}
-
+
return entry;
}
@@ -314,15 +322,15 @@ public class SchemaSubentryModifier
{
return desc.getExtensions().get( MetaSchemaConstants.X_SCHEMA ).get( 0 );
}
-
+
return MetaSchemaConstants.SCHEMA_OTHER;
}
-
-
+
+
private Entry getEntry( Dn dn, SyntaxCheckerDescription syntaxCheckerDescription )
{
Entry entry = new DefaultEntry( schemaManager, dn );
-
+
entry.put( SchemaConstants.OBJECT_CLASS_AT,
SchemaConstants.TOP_OC,
MetaSchemaConstants.META_TOP_OC,
@@ -334,14 +342,14 @@ public class SchemaSubentryModifier
if ( syntaxCheckerDescription.getBytecode() != null )
{
entry.put( MetaSchemaConstants.M_BYTECODE_AT,
- Base64.decode(syntaxCheckerDescription.getBytecode().toCharArray()) );
+ Base64.decode( syntaxCheckerDescription.getBytecode().toCharArray() ) );
}
-
+
if ( syntaxCheckerDescription.getDescription() != null )
{
entry.put( MetaSchemaConstants.M_DESCRIPTION_AT, syntaxCheckerDescription.getDescription() );
}
-
+
return entry;
}
}
Modified: directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/package-info.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/package-info.java?rev=1235306&r1=1235305&r2=1235306&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/package-info.java (original)
+++ directory/apacheds/trunk/interceptors/schema/src/main/java/org/apache/directory/server/core/schema/package-info.java Tue Jan 24 15:43:19 2012
@@ -53,3 +53,5 @@
*/
package org.apache.directory.server.core.schema;
+
+
Modified: directory/apacheds/trunk/interceptors/schema/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/schema/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java?rev=1235306&r1=1235305&r2=1235306&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/schema/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java (original)
+++ directory/apacheds/trunk/interceptors/schema/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java Tue Jan 24 15:43:19 2012
@@ -75,14 +75,14 @@ public class SchemaServiceTest
if ( !loaded )
{
- fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()) );
+ fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
}
loaded = schemaManager.loadWithDeps( "nis" );
if ( !loaded )
{
- fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()) );
+ fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
}
}
@@ -103,7 +103,7 @@ public class SchemaServiceTest
String[] expectedNames = new String[]
{ "sn", "generationQualifier", "ou", "c", "o", "l", "c-st", "givenName", "title", "cn", "initials",
"dmdName", "c-ou", "c-o", "apachePresence", "st", "c-l", "ads-serverId", "ads-indexAttributeId",
- "ads-transportId", "ads-directoryServiceId", "ads-Id", "ads-extendedOpId", "ads-pwdId",
+ "ads-transportId", "ads-directoryServiceId", "ads-Id", "ads-extendedOpId", "ads-pwdId",
"ads-compositeElement", "ads-replConsumerId", "ads-journalId", "ads-changeLogId", "ads-replProviderId" };
for ( String name : expectedNames )
Modified: directory/apacheds/trunk/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=1235306&r1=1235305&r2=1235306&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original)
+++ directory/apacheds/trunk/interceptors/subtree/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Tue Jan 24 15:43:19 2012
@@ -119,7 +119,8 @@ public class SubentryInterceptor extends
REMOVE,
REPLACE
}
-
+
+
/**
* Creates a new instance of SubentryInterceptor
*/
@@ -127,7 +128,6 @@ public class SubentryInterceptor extends
{
super( InterceptorEnum.SUBENTRY_INTERCEPTOR );
}
-
//-------------------------------------------------------------------------------------------
// Search filter methods
@@ -150,7 +150,6 @@ public class SubentryInterceptor extends
}
}
-
/**
* SearchResultFilter used to filter out normal entries but shows subentries based on
* objectClass values.
@@ -187,11 +186,11 @@ public class SubentryInterceptor extends
SUBENTRY_OPATTRS = new AttributeType[]
{
- ACCESS_CONTROL_SUBENTRIES_AT,
- SUBSCHEMA_SUBENTRY_AT,
- COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT,
- TRIGGER_EXECUTION_SUBENTRIES_AT
- };
+ ACCESS_CONTROL_SUBENTRIES_AT,
+ SUBSCHEMA_SUBENTRY_AT,
+ COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT,
+ TRIGGER_EXECUTION_SUBENTRIES_AT
+ };
ssParser = new SubtreeSpecificationParser( schemaManager );
@@ -328,17 +327,20 @@ public class SubentryInterceptor extends
// found the subentry request control so we return its value
if ( opContext.hasRequestControl( SUBENTRY_CONTROL ) )
{
- SubentriesDecorator subentriesDecorator = ( SubentriesDecorator ) opContext.getRequestControl( SUBENTRY_CONTROL );
+ SubentriesDecorator subentriesDecorator = ( SubentriesDecorator ) opContext
+ .getRequestControl( SUBENTRY_CONTROL );
return subentriesDecorator.getDecorated().isVisible();
}
return false;
}
+
/**
* Update all the entries under an AP adding the
*/
- private void updateEntries( OperationEnum operation, CoreSession session, Dn subentryDn, Dn apDn, SubtreeSpecification ss, Dn baseDn, List<Attribute> operationalAttributes ) throws LdapException
+ private void updateEntries( OperationEnum operation, CoreSession session, Dn subentryDn, Dn apDn,
+ SubtreeSpecification ss, Dn baseDn, List<Attribute> operationalAttributes ) throws LdapException
{
ExprNode filter = new PresenceNode( OBJECT_CLASS_AT ); // (objectClass=*)
SearchControls controls = new SearchControls();
@@ -365,19 +367,19 @@ public class SubentryInterceptor extends
switch ( operation )
{
- case ADD :
+ case ADD:
modifications = getOperationalModsForAdd( candidate, operationalAttributes );
break;
- case REMOVE :
+ case REMOVE:
modifications = getOperationalModsForRemove( subentryDn, candidate );
break;
- /*
- case REPLACE :
- modifications = getOperationalModsForReplace( subentryDn, candidate );
- break;
- */
+ /*
+ case REPLACE :
+ modifications = getOperationalModsForReplace( subentryDn, candidate );
+ break;
+ */
}
LOG.debug( "The entry {} has been evaluated to true for subentry {}", candidate.getDn(), subentryDn );
@@ -628,7 +630,8 @@ public class SubentryInterceptor extends
* Update the list of modifications with a modification associated with a specific
* role, if it's requested.
*/
- private void getOperationalModForReplace( boolean hasRole, AttributeType attributeType, Entry entry, Dn oldDn, Dn newDn, List<Modification> modifications ) throws LdapInvalidAttributeValueException
+ private void getOperationalModForReplace( boolean hasRole, AttributeType attributeType, Entry entry, Dn oldDn,
+ Dn newDn, List<Modification> modifications ) throws LdapInvalidAttributeValueException
{
String oldDnStr = oldDn.getNormName();
String newDnStr = newDn.getNormName();
@@ -656,14 +659,19 @@ public class SubentryInterceptor extends
* Get the list of modifications to be applied on an entry to inject the operational attributes
* associated with the administrative roles.
*/
- private List<Modification> getOperationalModsForReplace( Dn oldDn, Dn newDn, Subentry subentry, Entry entry ) throws Exception
+ private List<Modification> getOperationalModsForReplace( Dn oldDn, Dn newDn, Subentry subentry, Entry entry )
+ throws Exception
{
List<Modification> modifications = new ArrayList<Modification>();
- getOperationalModForReplace( subentry.isAccessControlAdminRole(), ACCESS_CONTROL_SUBENTRIES_AT, entry, oldDn, newDn, modifications );
- getOperationalModForReplace( subentry.isSchemaAdminRole(), SUBSCHEMA_SUBENTRY_AT, entry, oldDn, newDn, modifications );
- getOperationalModForReplace( subentry.isCollectiveAdminRole(), COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT, entry, oldDn, newDn, modifications );
- getOperationalModForReplace( subentry.isTriggersAdminRole(), TRIGGER_EXECUTION_SUBENTRIES_AT, entry, oldDn, newDn, modifications );
+ getOperationalModForReplace( subentry.isAccessControlAdminRole(), ACCESS_CONTROL_SUBENTRIES_AT, entry, oldDn,
+ newDn, modifications );
+ getOperationalModForReplace( subentry.isSchemaAdminRole(), SUBSCHEMA_SUBENTRY_AT, entry, oldDn, newDn,
+ modifications );
+ getOperationalModForReplace( subentry.isCollectiveAdminRole(), COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT, entry,
+ oldDn, newDn, modifications );
+ getOperationalModForReplace( subentry.isTriggersAdminRole(), TRIGGER_EXECUTION_SUBENTRIES_AT, entry, oldDn,
+ newDn, modifications );
return modifications;
}
@@ -691,13 +699,15 @@ public class SubentryInterceptor extends
if ( subentry.isCollectiveAdminRole() )
{
- Attribute collectiveAttributeSubentries = new DefaultAttribute( COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT, dn.getNormName() );
+ Attribute collectiveAttributeSubentries = new DefaultAttribute( COLLECTIVE_ATTRIBUTE_SUBENTRIES_AT,
+ dn.getNormName() );
attributes.add( collectiveAttributeSubentries );
}
if ( subentry.isTriggersAdminRole() )
{
- Attribute tiggerExecutionSubentries = new DefaultAttribute( TRIGGER_EXECUTION_SUBENTRIES_AT, dn.getNormName() );
+ Attribute tiggerExecutionSubentries = new DefaultAttribute( TRIGGER_EXECUTION_SUBENTRIES_AT,
+ dn.getNormName() );
attributes.add( tiggerExecutionSubentries );
}
@@ -747,7 +757,8 @@ public class SubentryInterceptor extends
* selected by the subtree specification. This method calculates the
* modify operation to be performed on the entry.
*/
- private List<Modification> getOperationalModsForAdd( Entry entry, List<Attribute> operationalAttributes ) throws LdapException
+ private List<Modification> getOperationalModsForAdd( Entry entry, List<Attribute> operationalAttributes )
+ throws LdapException
{
List<Modification> modifications = new ArrayList<Modification>();
@@ -764,11 +775,13 @@ public class SubentryInterceptor extends
newOperationalAttribute.add( value );
}
- modifications.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, newOperationalAttribute ) );
+ modifications.add( new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE,
+ newOperationalAttribute ) );
}
else
{
- modifications.add( new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, operationalAttribute ) );
+ modifications
+ .add( new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, operationalAttribute ) );
}
}
@@ -779,14 +792,16 @@ public class SubentryInterceptor extends
/**
* Get the list of modification to apply to all the entries
*/
- private List<Modification> getModsOnEntryModification( Dn name, Entry oldEntry, Entry newEntry ) throws LdapException
+ private List<Modification> getModsOnEntryModification( Dn name, Entry oldEntry, Entry newEntry )
+ throws LdapException
{
List<Modification> modList = new ArrayList<Modification>();
for ( Dn subentryDn : directoryService.getSubentryCache() )
{
Dn apDn = subentryDn.getParent();
- SubtreeSpecification ss = directoryService.getSubentryCache().getSubentry( subentryDn ).getSubtreeSpecification();
+ SubtreeSpecification ss = directoryService.getSubentryCache().getSubentry( subentryDn )
+ .getSubtreeSpecification();
boolean isOldEntrySelected = directoryService.getEvaluator().evaluate( ss, apDn, name, oldEntry );
boolean isNewEntrySelected = directoryService.getEvaluator().evaluate( ss, apDn, name, newEntry );
@@ -837,7 +852,7 @@ public class SubentryInterceptor extends
/**
* Update the Operational Attribute with the reference to the subentry
*/
- private void setOperationalAttribute( Entry entry, Dn subentryDn, AttributeType opAttr) throws LdapException
+ private void setOperationalAttribute( Entry entry, Dn subentryDn, AttributeType opAttr ) throws LdapException
{
Attribute operational = entry.get( opAttr );
@@ -915,7 +930,8 @@ public class SubentryInterceptor extends
Dn baseDn = apDn;
baseDn = baseDn.add( subentry.getSubtreeSpecification().getBase() );
- updateEntries( OperationEnum.ADD, addContext.getSession(), dn, apDn, subentry.getSubtreeSpecification(), baseDn, operationalAttributes );
+ updateEntries( OperationEnum.ADD, addContext.getSession(), dn, apDn, subentry.getSubtreeSpecification(),
+ baseDn, operationalAttributes );
// Store the newly modified entry into the context for later use in interceptor
// just in case
@@ -1004,7 +1020,8 @@ public class SubentryInterceptor extends
baseDn = baseDn.add( removedSubentry.getSubtreeSpecification().getBase() );
// Remove all the references to this removed subentry from all the selected entries
- updateEntries( OperationEnum.REMOVE, deleteContext.getSession(), dn, apDn, removedSubentry.getSubtreeSpecification(), baseDn, null );
+ updateEntries( OperationEnum.REMOVE, deleteContext.getSession(), dn, apDn,
+ removedSubentry.getSubtreeSpecification(), baseDn, null );
// Update the cache
directoryService.getSubentryCache().removeSubentry( dn );
@@ -1148,7 +1165,8 @@ public class SubentryInterceptor extends
Dn newBaseDn = apName;
newBaseDn = newBaseDn.add( ssNew.getBase() );
- searchOperationContext = new SearchOperationContext( modifyContext.getSession(), newBaseDn, filter, controls );
+ searchOperationContext = new SearchOperationContext( modifyContext.getSession(), newBaseDn, filter,
+ controls );
searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
subentries = nexus.search( searchOperationContext );
@@ -1270,7 +1288,8 @@ public class SubentryInterceptor extends
controls.setReturningAttributes( new String[]
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
- SearchOperationContext searchOperationContext = new SearchOperationContext( moveContext.getSession(), baseDn,
+ SearchOperationContext searchOperationContext = new SearchOperationContext( moveContext.getSession(),
+ baseDn,
filter, controls );
searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
@@ -1287,8 +1306,9 @@ public class SubentryInterceptor extends
if ( directoryService.getEvaluator().evaluate( ss, apName, dn, candidate ) )
{
- nexus.modify( new ModifyOperationContext( moveContext.getSession(), dn, getOperationalModsForReplace(
- oldDn, newName, subentry, candidate ) ) );
+ nexus.modify( new ModifyOperationContext( moveContext.getSession(), dn,
+ getOperationalModsForReplace(
+ oldDn, newName, subentry, candidate ) ) );
}
}
}
@@ -1374,7 +1394,8 @@ public class SubentryInterceptor extends
controls.setReturningAttributes( new String[]
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
- SearchOperationContext searchOperationContext = new SearchOperationContext( moveAndRenameContext.getSession(), baseDn,
+ SearchOperationContext searchOperationContext = new SearchOperationContext(
+ moveAndRenameContext.getSession(), baseDn,
filter, controls );
searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
@@ -1390,8 +1411,9 @@ public class SubentryInterceptor extends
if ( directoryService.getEvaluator().evaluate( ss, apName, dn, candidate ) )
{
- nexus.modify( new ModifyOperationContext( moveAndRenameContext.getSession(), dn, getOperationalModsForReplace(
- oldDn, newName, subentry, candidate ) ) );
+ nexus.modify( new ModifyOperationContext( moveAndRenameContext.getSession(), dn,
+ getOperationalModsForReplace(
+ oldDn, newName, subentry, candidate ) ) );
}
}
}
@@ -1442,7 +1464,7 @@ public class SubentryInterceptor extends
{
Dn oldDn = renameContext.getDn();
- Entry entry = ((ClonedServerEntry)renameContext.getEntry()).getClonedEntry();
+ Entry entry = ( ( ClonedServerEntry ) renameContext.getEntry() ).getClonedEntry();
if ( entry.contains( OBJECT_CLASS_AT, SchemaConstants.SUBENTRY_OC ) )
{
@@ -1467,7 +1489,8 @@ public class SubentryInterceptor extends
controls.setReturningAttributes( new String[]
{ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.ALL_USER_ATTRIBUTES } );
- SearchOperationContext searchOperationContext = new SearchOperationContext( renameContext.getSession(), baseDn,
+ SearchOperationContext searchOperationContext = new SearchOperationContext( renameContext.getSession(),
+ baseDn,
filter, controls );
searchOperationContext.setAliasDerefMode( AliasDerefMode.NEVER_DEREF_ALIASES );
@@ -1483,8 +1506,9 @@ public class SubentryInterceptor extends
if ( directoryService.getEvaluator().evaluate( ss, apName, dn, candidate ) )
{
- nexus.modify( new ModifyOperationContext( renameContext.getSession(), dn, getOperationalModsForReplace(
- oldDn, newName, subentry, candidate ) ) );
+ nexus.modify( new ModifyOperationContext( renameContext.getSession(), dn,
+ getOperationalModsForReplace(
+ oldDn, newName, subentry, candidate ) ) );
}
}
}
Modified: directory/apacheds/trunk/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java?rev=1235306&r1=1235305&r2=1235306&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java (original)
+++ directory/apacheds/trunk/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java Tue Jan 24 15:43:19 2012
@@ -19,6 +19,7 @@
*/
package org.apache.directory.server.core.subtree;
+
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -57,7 +58,7 @@ public class RefinementEvaluatorTest
{
/** the SchemaManager instance */
private static SchemaManager schemaManager;
-
+
/** the refinement evaluator to test */
private static RefinementEvaluator evaluator;
@@ -66,13 +67,13 @@ public class RefinementEvaluatorTest
/** The CN_AT AttributeType */
private static AttributeType CN_AT;
-
-
+
+
/**
* Initializes the global registries.
* @throws javax.naming.NamingException if there is a failure loading the schema
*/
- @BeforeClass
+ @BeforeClass
public static void init() throws Exception
{
JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
@@ -83,12 +84,12 @@ public class RefinementEvaluatorTest
if ( !loaded )
{
- fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()) );
+ fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
}
RefinementLeafEvaluator leafEvaluator = new RefinementLeafEvaluator( schemaManager );
evaluator = new RefinementEvaluator( leafEvaluator );
-
+
OBJECT_CLASS_AT = schemaManager.getAttributeType( "objectClass" );
CN_AT = schemaManager.lookupAttributeTypeRegistry( "cn" );
}
@@ -97,7 +98,7 @@ public class RefinementEvaluatorTest
/**
* Sets evaluator and registries to null.
*/
- @AfterClass
+ @AfterClass
public static void tearDown()
{
evaluator = null;
@@ -108,7 +109,7 @@ public class RefinementEvaluatorTest
* Test cases for various bad combinations of arguments
* @throws Exception if something goes wrong
*/
- @Test
+ @Test
public void testForBadArguments() throws Exception
{
try
@@ -122,7 +123,7 @@ public class RefinementEvaluatorTest
try
{
- assertFalse( evaluator.evaluate( new EqualityNode( (String)null, new StringValue( "" ) ), null ) );
+ assertFalse( evaluator.evaluate( new EqualityNode( ( String ) null, new StringValue( "" ) ), null ) );
fail( "should never get here due to an IAE" );
}
catch ( IllegalArgumentException iae )
@@ -131,7 +132,7 @@ public class RefinementEvaluatorTest
try
{
- assertFalse( evaluator.evaluate( new EqualityNode( (String)null, new StringValue( "" ) ),
+ assertFalse( evaluator.evaluate( new EqualityNode( ( String ) null, new StringValue( "" ) ),
new DefaultAttribute( "cn", CN_AT ) ) );
fail( "should never get here due to an IAE" );
}
@@ -141,90 +142,97 @@ public class RefinementEvaluatorTest
}
- @Test
+ @Test
public void testMatchByName() throws Exception
{
Attribute objectClasses = null;
// positive test
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
- assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ), objectClasses ) );
+ assertTrue( evaluator
+ .evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ), objectClasses ) );
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person", "blah" );
- assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ), objectClasses ) );
+ assertTrue( evaluator
+ .evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ), objectClasses ) );
// negative tests
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "blah" ) ), objectClasses ) );
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "blah" );
- assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ), objectClasses ) );
+ assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ),
+ objectClasses ) );
}
- @Test
+ @Test
public void testMatchByOID() throws Exception
{
Attribute objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
-
+
// positive test
- assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.6" ) ), objectClasses ) );
+ assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.6" ) ),
+ objectClasses ) );
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person", "blah" );
- assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.6" ) ), objectClasses ) );
+ assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.6" ) ),
+ objectClasses ) );
// negative tests
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
- assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.5" ) ), objectClasses ) );
+ assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.5" ) ),
+ objectClasses ) );
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "blah" );
- assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.5" ) ), objectClasses ) );
+ assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.5" ) ),
+ objectClasses ) );
}
- @Test
+ @Test
public void testComplexOrRefinement() throws Exception
{
ExprNode refinement = null;
Attribute objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
String refStr = "(|(objectClass=person)(objectClass=organizationalUnit))";
-
+
refinement = FilterParser.parse( schemaManager, refStr );
assertTrue( evaluator.evaluate( refinement, objectClasses ) );
-
+
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "organizationalUnit" );
assertTrue( evaluator.evaluate( refinement, objectClasses ) );
-
+
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "domain" );
assertFalse( evaluator.evaluate( refinement, objectClasses ) );
}
- @Test
+ @Test
public void testComplexAndRefinement() throws Exception
{
ExprNode refinement = null;
Attribute objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
objectClasses.add( "organizationalUnit" );
String refStr = "(&(objectClass=person)(objectClass=organizationalUnit))";
-
- refinement = FilterParser.parse( schemaManager,refStr );
+
+ refinement = FilterParser.parse( schemaManager, refStr );
assertTrue( evaluator.evaluate( refinement, objectClasses ) );
-
+
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "organizationalUnit" );
assertFalse( evaluator.evaluate( refinement, objectClasses ) );
-
+
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
assertFalse( evaluator.evaluate( refinement, objectClasses ) );
-
+
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "domain" );
assertFalse( evaluator.evaluate( refinement, objectClasses ) );
}
- @Test
+ @Test
public void testComplexNotRefinement() throws Exception
{
ExprNode refinement = null;
@@ -234,10 +242,10 @@ public class RefinementEvaluatorTest
refinement = FilterParser.parse( schemaManager, refStr );
assertFalse( evaluator.evaluate( refinement, objectClasses ) );
-
+
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "organizationalUnit" );
assertTrue( evaluator.evaluate( refinement, objectClasses ) );
-
+
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "domain" );
assertTrue( evaluator.evaluate( refinement, objectClasses ) );
Modified: directory/apacheds/trunk/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java?rev=1235306&r1=1235305&r2=1235306&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java (original)
+++ directory/apacheds/trunk/interceptors/subtree/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java Tue Jan 24 15:43:19 2012
@@ -60,10 +60,10 @@ public class RefinementLeafEvaluatorTest
/** The ObjectClass AttributeType */
private static AttributeType OBJECT_CLASS_AT;
-
+
/** The CN AttributeType */
private static AttributeType CN_AT;
-
+
/** the refinement leaf evaluator to test */
private static RefinementLeafEvaluator evaluator;
@@ -72,7 +72,7 @@ public class RefinementLeafEvaluatorTest
* Initializes the global registries.
* @throws javax.naming.NamingException if there is a failure loading the schema
*/
- @BeforeClass
+ @BeforeClass
public static void init() throws Exception
{
JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
@@ -83,20 +83,20 @@ public class RefinementLeafEvaluatorTest
if ( !loaded )
{
- fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()) );
+ fail( "Schema load failed : " + Exceptions.printErrors( schemaManager.getErrors() ) );
}
-
+
OBJECT_CLASS_AT = schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASS_AT );
CN_AT = schemaManager.getAttributeType( SchemaConstants.CN_AT );
evaluator = new RefinementLeafEvaluator( schemaManager );
}
-
+
/**
* Sets evaluator and registries to null.
*/
- @AfterClass
+ @AfterClass
public static void tearDown()
{
evaluator = null;
@@ -107,7 +107,7 @@ public class RefinementLeafEvaluatorTest
* Test cases for various bad combinations of arguments
* @throws Exception if something goes wrongg
*/
- @Test
+ @Test
public void testForBadArguments() throws Exception
{
Attribute objectClasses = null;
@@ -161,45 +161,52 @@ public class RefinementLeafEvaluatorTest
}
- @Test
+ @Test
public void testMatchByName() throws Exception
{
// positive test
Attribute objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
- assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ), objectClasses ) );
+ assertTrue( evaluator
+ .evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ), objectClasses ) );
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT );
objectClasses.add( "person" );
objectClasses.add( "blah" );
- assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ), objectClasses ) );
+ assertTrue( evaluator
+ .evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ), objectClasses ) );
// negative tests
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "blah" ) ), objectClasses ) );
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "blah" );
- assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ), objectClasses ) );
+ assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "person" ) ),
+ objectClasses ) );
}
- @Test
+ @Test
public void testMatchByOID() throws Exception
{
Attribute objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
// positive test
- assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.6" ) ), objectClasses ) );
+ assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.6" ) ),
+ objectClasses ) );
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT );
objectClasses.add( "person" );
objectClasses.add( "blah" );
- assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.6" ) ), objectClasses ) );
+ assertTrue( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.6" ) ),
+ objectClasses ) );
// negative tests
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "person" );
- assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.5" ) ), objectClasses ) );
+ assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.5" ) ),
+ objectClasses ) );
objectClasses = new DefaultAttribute( OBJECT_CLASS_AT, "blah" );
- assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.5" ) ), objectClasses ) );
+ assertFalse( evaluator.evaluate( new EqualityNode( OBJECT_CLASS_AT, new StringValue( "2.5.6.5" ) ),
+ objectClasses ) );
}
}