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 2010/01/06 19:27:19 UTC
svn commit: r896599 [15/30] - in /directory/apacheds/trunk: ./
avl-partition/ avl-partition/src/ avl-partition/src/main/
avl-partition/src/main/java/ avl-partition/src/main/java/org/
avl-partition/src/main/java/org/apache/ avl-partition/src/main/java/o...
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributeInterceptor.java Wed Jan 6 18:26:43 2010
@@ -20,6 +20,11 @@
package org.apache.directory.server.core.collective;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.NamingException;
+
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.entry.DefaultServerAttribute;
@@ -37,15 +42,12 @@
import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
import org.apache.directory.server.core.partition.ByPassConstants;
import org.apache.directory.server.core.partition.PartitionNexus;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.schema.AttributeType;
-
-import java.util.HashSet;
-import java.util.Set;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
/**
@@ -62,8 +64,8 @@
*/
public class CollectiveAttributeInterceptor extends BaseInterceptor
{
- /** The attributeType registry */
- private AttributeTypeRegistry atRegistry;
+ /** The SchemaManager */
+ private SchemaManager schemaManager;
private PartitionNexus nexus;
@@ -82,7 +84,7 @@
if ( name.isNormalized() == false )
{
- name = LdapDN.normalize( name, atRegistry.getNormalizerMapping() );
+ name = LdapDN.normalize( name, schemaManager.getNormalizerMapping() );
}
String[] retAttrs = operation.getSearchControls().getReturningAttributes();
@@ -94,9 +96,9 @@
public void init( DirectoryService directoryService ) throws Exception
{
super.init( directoryService );
+ schemaManager = directoryService.getSchemaManager();
nexus = directoryService.getPartitionNexus();
- atRegistry = directoryService.getRegistries().getAttributeTypeRegistry();
- collectiveAttributesSchemaChecker = new CollectiveAttributesSchemaChecker( nexus, atRegistry );
+ collectiveAttributesSchemaChecker = new CollectiveAttributesSchemaChecker( nexus, schemaManager );
}
@@ -154,7 +156,7 @@
for ( Value<?> value:collectiveExclusions )
{
- AttributeType attrType = atRegistry.lookup( value.getString() );
+ AttributeType attrType = schemaManager.lookupAttributeTypeRegistry( value.getString() );
exclusions.add( attrType.getOid() );
}
}
@@ -183,7 +185,7 @@
}
else
{
- retIdsSet.add( atRegistry.lookup( retAttr ).getOid() );
+ retIdsSet.add( schemaManager.lookupAttributeTypeRegistry( retAttr ).getOid() );
}
}
@@ -233,11 +235,11 @@
continue;
}
- AttributeType retType = atRegistry.lookup( retId );
+ AttributeType retType = schemaManager.lookupAttributeTypeRegistry( retId );
if ( allSuperTypes.contains( retType ) )
{
- retIdsSet.add( atRegistry.lookup( attrId ).getOid() );
+ retIdsSet.add( schemaManager.lookupAttributeTypeRegistry( attrId ).getOid() );
break;
}
}
@@ -247,7 +249,7 @@
* then bypass the inclusion process.
*/
if ( !( retIdsSet.contains( SchemaConstants.ALL_USER_ATTRIBUTES ) ||
- retIdsSet.contains( atRegistry.lookup( attrId ).getOid() ) ) )
+ retIdsSet.contains( schemaManager.lookupAttributeTypeRegistry( attrId ).getOid() ) ) )
{
continue;
}
@@ -260,7 +262,7 @@
*/
if ( entryColAttr == null )
{
- entryColAttr = new DefaultServerAttribute( attrId, atRegistry.lookup( attrId ) );
+ entryColAttr = new DefaultServerAttribute( attrId, schemaManager.lookupAttributeTypeRegistry( attrId ) );
entry.put( entryColAttr );
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/collective/CollectiveAttributesSchemaChecker.java Wed Jan 6 18:26:43 2010
@@ -30,7 +30,6 @@
import org.apache.directory.server.core.interceptor.context.OperationContext;
import org.apache.directory.server.core.partition.ByPassConstants;
import org.apache.directory.server.core.partition.PartitionNexus;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Modification;
@@ -40,6 +39,7 @@
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
import org.apache.directory.shared.ldap.schema.SchemaUtils;
@@ -52,12 +52,12 @@
public class CollectiveAttributesSchemaChecker
{
private PartitionNexus nexus = null;
- private AttributeTypeRegistry attrTypeRegistry = null;
+ private SchemaManager schemaManager = null;
- public CollectiveAttributesSchemaChecker( PartitionNexus nexus, AttributeTypeRegistry attrTypeRegistry )
+ public CollectiveAttributesSchemaChecker( PartitionNexus nexus, SchemaManager schemaManager )
{
this.nexus = nexus;
- this.attrTypeRegistry = attrTypeRegistry;
+ this.schemaManager = schemaManager;
}
/* package scope*/ void checkAdd( LdapDN normName, ServerEntry entry ) throws Exception
@@ -113,13 +113,13 @@
if ( attrType == null )
{
- if ( !attrTypeRegistry.hasAttributeType( attr.getUpId() ) )
+ if ( !schemaManager.getAttributeTypeRegistry().contains( attr.getUpId() ) )
{
throw new LdapInvalidAttributeIdentifierException();
}
else
{
- attrType = attrTypeRegistry.lookup( attr.getUpId() );
+ attrType = schemaManager.lookupAttributeTypeRegistry( attr.getUpId() );
}
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/AttributesPropertyEditor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/AttributesPropertyEditor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/AttributesPropertyEditor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/configuration/AttributesPropertyEditor.java Wed Jan 6 18:26:43 2010
@@ -19,6 +19,15 @@
*/
package org.apache.directory.server.core.configuration;
+import java.beans.PropertyEditor;
+import java.beans.PropertyEditorSupport;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.shared.ldap.entry.Entry;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -28,14 +37,6 @@
import org.apache.directory.shared.ldap.util.AttributeUtils;
import org.apache.directory.shared.ldap.util.StringTools;
-import javax.naming.NamingException;
-import javax.naming.directory.Attributes;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorSupport;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-
/**
* A JavaBeans {@link PropertyEditor} that can convert {@link Attributes} to
@@ -68,7 +69,6 @@
/**
* Returns LDIF string of {@link Attributes} object.
*/
- @SuppressWarnings("deprecation")
public String getAsText()
{
Attributes attrs = (Attributes) getValue();
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java Wed Jan 6 18:26:43 2010
@@ -43,13 +43,12 @@
import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
import org.apache.directory.server.core.normalization.FilterNormalizingVisitor;
import org.apache.directory.server.core.partition.ByPassConstants;
-import org.apache.directory.server.schema.ConcreteNameComponentNormalizer;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
import org.apache.directory.shared.ldap.filter.ExprNode;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
-
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.normalizers.ConcreteNameComponentNormalizer;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -82,11 +81,11 @@
super.init( ds );
this.ds = ds;
- OidRegistry oidRegistry = ds.getRegistries().getOidRegistry();
- AttributeTypeRegistry attributeRegistry = ds.getRegistries().getAttributeTypeRegistry();
- NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( attributeRegistry, oidRegistry );
- filterNormalizer = new FilterNormalizingVisitor( ncn, ds.getRegistries() );
- evaluator = new ExpressionEvaluator( oidRegistry, attributeRegistry );
+ OidRegistry oidRegistry = ds.getSchemaManager().getGlobalOidRegistry();
+ SchemaManager schemaManager = ds.getSchemaManager();
+ NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( schemaManager );
+ filterNormalizer = new FilterNormalizingVisitor( ncn, schemaManager );
+ evaluator = new ExpressionEvaluator( oidRegistry, schemaManager );
executor = new ThreadPoolExecutor( 1, 10, 1000, TimeUnit.MILLISECONDS,
new ArrayBlockingQueue<Runnable>( 100 ) );
@@ -192,6 +191,7 @@
{
ClonedServerEntry oriEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(), oriEntry );
+
next.modify( opContext );
if ( selecting.isEmpty() )
@@ -199,6 +199,10 @@
return;
}
+ // Get the modified entry
+ ClonedServerEntry alteredEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
+ opContext.setAlteredEntry( alteredEntry );
+
for ( final RegistrationEntry registration : selecting )
{
if ( EventType.isModify( registration.getCriteria().getEventMask() ) )
@@ -213,6 +217,7 @@
{
ClonedServerEntry oriEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(), oriEntry );
+
next.rename( opContext );
if ( selecting.isEmpty() )
@@ -220,7 +225,9 @@
return;
}
- opContext.setAlteredEntry( opContext.lookup( opContext.getNewDn(), ByPassConstants.LOOKUP_BYPASS ) );
+ // Get the modifed entry
+ ClonedServerEntry alteredEntry = opContext.lookup( opContext.getNewDn(), ByPassConstants.LOOKUP_BYPASS );
+ opContext.setAlteredEntry( alteredEntry );
for ( final RegistrationEntry registration : selecting )
{
@@ -265,6 +272,7 @@
{
ClonedServerEntry oriEntry = opContext.lookup( opContext.getDn(), ByPassConstants.LOOKUP_BYPASS );
List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(), oriEntry );
+
next.move( opContext );
if ( selecting.isEmpty() )
@@ -326,7 +334,7 @@
*/
public void addListener( DirectoryListener listener, NotificationCriteria criteria ) throws Exception
{
- criteria.getBase().normalize( ds.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+ criteria.getBase().normalize( ds.getSchemaManager().getNormalizerMapping() );
ExprNode result = ( ExprNode ) criteria.getFilter().accept( filterNormalizer );
criteria.setFilter( result );
registrations.add( new RegistrationEntry( listener, criteria ) );
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/ExpressionEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/ExpressionEvaluator.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/ExpressionEvaluator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/ExpressionEvaluator.java Wed Jan 6 18:26:43 2010
@@ -23,13 +23,13 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
import org.apache.directory.shared.ldap.filter.AndNode;
import org.apache.directory.shared.ldap.filter.BranchNode;
import org.apache.directory.shared.ldap.filter.ExprNode;
import org.apache.directory.shared.ldap.filter.NotNode;
import org.apache.directory.shared.ldap.filter.OrNode;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
@@ -55,7 +55,7 @@
*
* @param leafEvaluator handles leaf node evaluation.
*/
- public ExpressionEvaluator(LeafEvaluator leafEvaluator)
+ public ExpressionEvaluator( LeafEvaluator leafEvaluator )
{
this.leafEvaluator = leafEvaluator;
}
@@ -68,11 +68,11 @@
* @param oidRegistry the oid reg used for attrID to oid resolution
* @param attributeTypeRegistry the attribtype reg used for value comparison
*/
- public ExpressionEvaluator(OidRegistry oidRegistry, AttributeTypeRegistry attributeTypeRegistry)
+ public ExpressionEvaluator( OidRegistry oidRegistry, SchemaManager schemaManager )
{
SubstringEvaluator substringEvaluator = null;
- substringEvaluator = new SubstringEvaluator( oidRegistry, attributeTypeRegistry );
- leafEvaluator = new LeafEvaluator( oidRegistry, attributeTypeRegistry, substringEvaluator );
+ substringEvaluator = new SubstringEvaluator( schemaManager );
+ leafEvaluator = new LeafEvaluator( schemaManager, substringEvaluator );
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/LeafEvaluator.java Wed Jan 6 18:26:43 2010
@@ -25,8 +25,6 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
import org.apache.directory.shared.ldap.NotImplementedException;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Value;
@@ -42,8 +40,10 @@
import org.apache.directory.shared.ldap.filter.SimpleNode;
import org.apache.directory.shared.ldap.filter.SubstringNode;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.LdapComparator;
import org.apache.directory.shared.ldap.schema.MatchingRule;
import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
/**
@@ -56,17 +56,19 @@
{
/** equality matching type constant */
private static final int EQUALITY_MATCH = 0;
+
/** ordering matching type constant */
private static final int ORDERING_MATCH = 1;
+
/** substring matching type constant */
private static final int SUBSTRING_MATCH = 3;
- /** Oid Registry used to translate attributeIds to OIDs */
- private OidRegistry oidRegistry;
- /** AttributeType registry needed for normalizing and comparing values */
- private AttributeTypeRegistry attributeTypeRegistry;
+ /** SchemaManager needed for normalizing and comparing values */
+ private SchemaManager schemaManager;
+
/** Substring node evaluator we depend on */
private SubstringEvaluator substringEvaluator;
+
/** ScopeNode evaluator we depend on */
private ScopeEvaluator scopeEvaluator;
@@ -80,11 +82,10 @@
*
* @param substringEvaluator
*/
- public LeafEvaluator( OidRegistry oidRegistry, AttributeTypeRegistry attributeTypeRegistry,
+ public LeafEvaluator( SchemaManager schemaManager,
SubstringEvaluator substringEvaluator )
{
- this.oidRegistry = oidRegistry;
- this.attributeTypeRegistry = attributeTypeRegistry;
+ this.schemaManager = schemaManager;
this.scopeEvaluator = new ScopeEvaluator();
this.substringEvaluator = substringEvaluator;
}
@@ -162,7 +163,7 @@
String attrId = node.getAttribute();
// get the attribute associated with the node
- AttributeType type = attributeTypeRegistry.lookup( oidRegistry.getOid( attrId ) );
+ AttributeType type = schemaManager.lookupAttributeTypeRegistry( attrId );
EntryAttribute attr = entry.get( type );
// If we do not have the attribute just return false
@@ -259,7 +260,7 @@
}
// check if AVA value exists in attribute
- AttributeType at = attributeTypeRegistry.lookup( node.getAttribute() );
+ AttributeType at = schemaManager.lookupAttributeTypeRegistry( node.getAttribute() );
Value<?> value = null;
if ( at.getSyntax().isHumanReadable() )
@@ -319,10 +320,10 @@
* @return the comparator for equality matching
* @throws javax.naming.NamingException if there is a failure
*/
- private Comparator<?> getComparator( String attrId ) throws NamingException
+ private LdapComparator<? super Object> getComparator( String attrId ) throws NamingException
{
MatchingRule mrule = getMatchingRule( attrId, EQUALITY_MATCH );
- return mrule.getComparator();
+ return mrule.getLdapComparator();
}
@@ -350,8 +351,7 @@
private MatchingRule getMatchingRule( String attrId, int matchType ) throws NamingException
{
MatchingRule mrule = null;
- String oid = oidRegistry.getOid( attrId );
- AttributeType type = attributeTypeRegistry.lookup( oid );
+ AttributeType type = schemaManager.lookupAttributeTypeRegistry( attrId );
switch ( matchType )
{
@@ -360,7 +360,7 @@
break;
case ( SUBSTRING_MATCH ):
- mrule = type.getSubstr();
+ mrule = type.getSubstring();
break;
case ( ORDERING_MATCH ):
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/SubstringEvaluator.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/SubstringEvaluator.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/SubstringEvaluator.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/event/SubstringEvaluator.java Wed Jan 6 18:26:43 2010
@@ -26,8 +26,6 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.filter.ExprNode;
@@ -35,6 +33,7 @@
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.MatchingRule;
import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
/**
@@ -45,10 +44,8 @@
*/
public class SubstringEvaluator implements Evaluator
{
- /** Oid Registry used to translate attributeIds to OIDs */
- private OidRegistry oidRegistry;
- /** AttributeType registry needed for normalizing and comparing values */
- private AttributeTypeRegistry attributeTypeRegistry;
+ /** SchemaManager needed for normalizing and comparing values */
+ private SchemaManager schemaManager;
/**
@@ -57,10 +54,9 @@
* @param oidRegistry the OID registry for name to OID mapping
* @param attributeTypeRegistry the attributeType registry
*/
- public SubstringEvaluator(OidRegistry oidRegistry, AttributeTypeRegistry attributeTypeRegistry)
+ public SubstringEvaluator( SchemaManager schemaManager )
{
- this.oidRegistry = oidRegistry;
- this.attributeTypeRegistry = attributeTypeRegistry;
+ this.schemaManager = schemaManager;
}
@@ -71,9 +67,9 @@
{
Pattern regex = null;
SubstringNode snode = (SubstringNode)node;
- String oid = oidRegistry.getOid( snode.getAttribute() );
- AttributeType type = attributeTypeRegistry.lookup( oid );
- MatchingRule matchingRule = type.getSubstr();
+ String oid = schemaManager.getAttributeTypeRegistry().getOidByName( snode.getAttribute() );
+ AttributeType type = schemaManager.lookupAttributeTypeRegistry( oid );
+ MatchingRule matchingRule = type.getSubstring();
if ( matchingRule == null )
{
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Wed Jan 6 18:26:43 2010
@@ -20,13 +20,15 @@
package org.apache.directory.server.core.exception;
+import java.util.List;
+
import org.apache.commons.collections.map.LRUMap;
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.entry.ServerAttribute;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.filtering.EntryFilteringCursor;
import org.apache.directory.server.core.filtering.BaseEntryFilteringCursor;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
import org.apache.directory.server.core.interceptor.BaseInterceptor;
import org.apache.directory.server.core.interceptor.NextInterceptor;
import org.apache.directory.server.core.interceptor.context.AddOperationContext;
@@ -59,10 +61,6 @@
import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
-
-import java.util.List;
-import java.util.Map;
/**
@@ -84,11 +82,6 @@
/**
- * The OIDs normalizer map
- */
- private Map<String, OidNormalizer> normalizerMap;
-
- /**
* A cache to store entries which are not aliases.
* It's a speedup, we will be able to avoid backend lookups.
*
@@ -124,10 +117,9 @@
{
this.directoryService = directoryService;
nexus = directoryService.getPartitionNexus();
- normalizerMap = directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping();
Value<?> attr = nexus.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
subschemSubentryDn = new LdapDN( attr.getString() );
- subschemSubentryDn.normalize( normalizerMap );
+ subschemSubentryDn.normalize( directoryService.getSchemaManager().getNormalizerMapping() );
}
@@ -153,8 +145,8 @@
// check if the entry already exists
if ( nextInterceptor.hasEntry( new EntryOperationContext( opContext.getSession(), name ) ) )
{
- LdapNameAlreadyBoundException ne = new LdapNameAlreadyBoundException( name.getUpName() + " already exists!" );
- ne.setResolvedName( new LdapDN( name.getUpName() ) );
+ LdapNameAlreadyBoundException ne = new LdapNameAlreadyBoundException( name.getName() + " already exists!" );
+ ne.setResolvedName( new LdapDN( name.getName() ) );
throw ne;
}
@@ -162,7 +154,7 @@
name ) );
// we're adding the suffix entry so just ignore stuff to mess with the parent
- if ( suffix.getNormName().equals( name.getNormName() ) )
+ if ( suffix.equals( name ) )
{
nextInterceptor.add( opContext );
return;
@@ -191,10 +183,10 @@
}
catch ( Exception e )
{
- LdapNameNotFoundException e2 = new LdapNameNotFoundException( "Parent " + parentDn.getUpName()
+ LdapNameNotFoundException e2 = new LdapNameNotFoundException( "Parent " + parentDn.getName()
+ " not found" );
e2.setResolvedName( new LdapDN( nexus.getMatchedName(
- new GetMatchedNameOperationContext( opContext.getSession(), parentDn ) ).getUpName() ) );
+ new GetMatchedNameOperationContext( opContext.getSession(), parentDn ) ).getName() ) );
throw e2;
}
@@ -202,10 +194,10 @@
if ( objectClass.contains( SchemaConstants.ALIAS_OC ) )
{
- String msg = "Attempt to add entry to alias '" + name.getUpName() + "' not allowed.";
+ String msg = "Attempt to add entry to alias '" + name.getName() + "' not allowed.";
ResultCodeEnum rc = ResultCodeEnum.ALIAS_PROBLEM;
LdapNamingException e = new LdapNamingException( msg, rc );
- e.setResolvedName( new LdapDN( parentDn.getUpName() ) );
+ e.setResolvedName( new LdapDN( parentDn.getName() ) );
throw e;
}
else
@@ -255,7 +247,7 @@
if ( hasChildren )
{
LdapContextNotEmptyException e = new LdapContextNotEmptyException();
- e.setResolvedName( new LdapDN( name.getUpName() ) );
+ e.setResolvedName( new LdapDN( name.getName() ) );
throw e;
}
@@ -375,7 +367,7 @@
{
LdapDN dn = opContext.getDn();
- if ( dn.getNormName().equalsIgnoreCase( subschemSubentryDn.getNormName() ) )
+ if ( dn.equals( subschemSubentryDn ) )
{
throw new LdapOperationNotSupportedException(
"Can not allow the renaming of the subschemaSubentry (" +
@@ -383,21 +375,25 @@
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
- // check if entry to rename exists
- String msg = "Attempt to rename non-existant entry: ";
- assertHasEntry( nextInterceptor, opContext, msg, dn );
-
+ // Check to see if the renamed entry exists
+ if ( opContext.getEntry() == null )
+ {
+ // This is a nonsense : we can't rename an entry which does not exist
+ // on the server
+ LdapNameNotFoundException ldnfe;
+ ldnfe = new LdapNameNotFoundException( "target entry " + dn.getName() + " des not exist!" );
+ ldnfe.setResolvedName( new LdapDN( dn.getName() ) );
+ throw ldnfe;
+ }
+
// check to see if target entry exists
- LdapDN newDn = ( LdapDN ) dn.clone();
- newDn.remove( dn.size() - 1 );
- newDn.add( opContext.getNewRdn() );
- newDn.normalize( normalizerMap );
+ LdapDN newDn = opContext.getNewDn();
if ( nextInterceptor.hasEntry( new EntryOperationContext( opContext.getSession(), newDn ) ) )
{
LdapNameAlreadyBoundException e;
- e = new LdapNameAlreadyBoundException( "target entry " + newDn.getUpName() + " already exists!" );
- e.setResolvedName( new LdapDN( newDn.getUpName() ) );
+ e = new LdapNameAlreadyBoundException( "target entry " + newDn.getName() + " already exists!" );
+ e.setResolvedName( new LdapDN( newDn.getName() ) );
throw e;
}
@@ -447,13 +443,13 @@
if ( nextInterceptor.hasEntry( new EntryOperationContext( opContext.getSession(), target ) ) )
{
// we must calculate the resolved name using the user provided Rdn value
- String upRdn = new LdapDN( oriChildName.getUpName() ).get( oriChildName.size() - 1 );
+ String upRdn = new LdapDN( oriChildName.getName() ).get( oriChildName.size() - 1 );
LdapDN upTarget = ( LdapDN ) newParentName.clone();
upTarget.add( upRdn );
LdapNameAlreadyBoundException e;
- e = new LdapNameAlreadyBoundException( "target entry " + upTarget.getUpName() + " already exists!" );
- e.setResolvedName( new LdapDN( upTarget.getUpName() ) );
+ e = new LdapNameAlreadyBoundException( "target entry " + upTarget.getName() + " already exists!" );
+ e.setResolvedName( new LdapDN( upTarget.getName() ) );
throw e;
}
@@ -506,8 +502,8 @@
upTarget.add( opContext.getNewRdn() );
LdapNameAlreadyBoundException e;
- e = new LdapNameAlreadyBoundException( "target entry " + upTarget.getUpName() + " already exists!" );
- e.setResolvedName( new LdapDN( upTarget.getUpName() ) );
+ e = new LdapNameAlreadyBoundException( "target entry " + upTarget.getName() + " already exists!" );
+ e.setResolvedName( new LdapDN( upTarget.getName() ) );
throw e;
}
@@ -578,17 +574,17 @@
if ( msg != null )
{
- e = new LdapNameNotFoundException( msg + dn.getUpName() );
+ e = new LdapNameNotFoundException( msg + dn.getName() );
}
else
{
- e = new LdapNameNotFoundException( dn.getUpName() );
+ e = new LdapNameNotFoundException( dn.getName() );
}
e.setResolvedName(
new LdapDN(
opContext.getSession().getDirectoryService().getOperationManager().getMatchedName(
- new GetMatchedNameOperationContext( opContext.getSession(), dn ) ).getUpName() ) );
+ new GetMatchedNameOperationContext( opContext.getSession(), dn ) ).getName() ) );
throw e;
}
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/journal/DefaultJournal.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/journal/DefaultJournal.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/journal/DefaultJournal.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/journal/DefaultJournal.java Wed Jan 6 18:26:43 2010
@@ -19,7 +19,7 @@
package org.apache.directory.server.core.journal;
import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.LdapPrincipal;
import org.apache.directory.shared.ldap.ldif.LdifEntry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/journal/DefaultJournalStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/journal/DefaultJournalStore.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/journal/DefaultJournalStore.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/journal/DefaultJournalStore.java Wed Jan 6 18:26:43 2010
@@ -29,14 +29,12 @@
import javax.naming.NamingException;
import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.server.core.LdapPrincipal;
import org.apache.directory.shared.ldap.ldif.LdifEntry;
import org.apache.directory.shared.ldap.ldif.LdifUtils;
/**
*
- * @author elecharny
- *
* @org.apache.xbean.XBean
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java Wed Jan 6 18:26:43 2010
@@ -25,7 +25,6 @@
import javax.naming.NamingException;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
import org.apache.directory.shared.ldap.filter.ApproximateNode;
import org.apache.directory.shared.ldap.filter.BranchNode;
import org.apache.directory.shared.ldap.filter.EqualityNode;
@@ -39,6 +38,7 @@
import org.apache.directory.shared.ldap.filter.PresenceNode;
import org.apache.directory.shared.ldap.filter.SubstringNode;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
/**
@@ -49,18 +49,19 @@
*/
public class ExpandingVisitor implements FilterVisitor
{
- private final AttributeTypeRegistry attrRegistry;
-
-
+ /** The schemaManager */
+ private SchemaManager schemaManager;
+
+
/**
*
* Creates a new instance of ExpandingVisitor.
*
- * @param attrRegistry The AttributeType registry
+ * @param schemaManager The schemaManager
*/
- public ExpandingVisitor( AttributeTypeRegistry attrRegistry )
+ public ExpandingVisitor( SchemaManager schemaManager )
{
- this.attrRegistry = attrRegistry;
+ this.schemaManager = schemaManager;
}
@@ -102,7 +103,7 @@
try
{
- if ( attrRegistry.hasDescendants( leaf.getAttribute() ) )
+ if ( schemaManager.getAttributeTypeRegistry().hasDescendants( leaf.getAttribute() ) )
{
// create a new OR node to hold all descendent forms
// add to this node the generalized leaf node and
@@ -112,7 +113,7 @@
children.set( childNumber++, orNode );
// iterate through descendants adding them to the orNode
- Iterator<AttributeType> descendants = attrRegistry.descendants( leaf.getAttribute() );
+ Iterator<AttributeType> descendants = schemaManager.getAttributeTypeRegistry().descendants( leaf.getAttribute() );
while ( descendants.hasNext() )
{
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/FilterNormalizingVisitor.java Wed Jan 6 18:26:43 2010
@@ -25,9 +25,7 @@
import javax.naming.NamingException;
-import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
import org.apache.directory.shared.ldap.filter.AndNode;
import org.apache.directory.shared.ldap.filter.BranchNode;
@@ -41,6 +39,7 @@
import org.apache.directory.shared.ldap.filter.SubstringNode;
import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -56,7 +55,7 @@
* might make some partition implementations choke. To avoid this problem we clean up branch
* nodes that don't make sense. For example all BranchNodes without children are just
* removed. An AND and OR BranchNode with a single child is replaced with it's child for
- * all but the topmost branchnode which we cannot replace. So again the top most branch
+ * all but the topmost branch node which we cannot replace. So again the top most branch
* node must be inspected by code outside of this visitor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
@@ -71,8 +70,8 @@
private final NameComponentNormalizer ncn;
/** the global registries used to resolve OIDs for attributeType ids */
- private final Registries registries;
-
+ private final SchemaManager schemaManager;
+
/**
* Chars which need to be escaped in a filter
@@ -118,10 +117,10 @@
* @param ncn The name component normalizer to use
* @param registries The global registries
*/
- public FilterNormalizingVisitor( NameComponentNormalizer ncn, Registries registries )
+ public FilterNormalizingVisitor( NameComponentNormalizer ncn, SchemaManager schemaManager )
{
this.ncn = ncn;
- this.registries = registries;
+ this.schemaManager = schemaManager;
}
@@ -141,7 +140,7 @@
{
Value<?> normalized = null;
- AttributeType attributeType = registries.getAttributeTypeRegistry().lookup( attribute );
+ AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( attribute );
if ( attributeType.getSyntax().isHumanReadable() )
{
@@ -170,18 +169,10 @@
* @param node the node to visit
* @return The visited node
*/
- private ExprNode visitPresenceNode( PresenceNode node )
+ private ExprNode visitPresenceNode( PresenceNode node ) throws NamingException
{
- try
- {
- node.setAttribute( registries.getOidRegistry().getOid( node.getAttribute() ) );
- return node;
- }
- catch ( NamingException ne )
- {
- log.warn( "Failed to normalize filter node attribute: {}, error: {}", node.getAttribute(), ne.getMessage() );
- return null;
- }
+ node.setAttribute( schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute() ) );
+ return node;
}
@@ -196,7 +187,7 @@
* @param node the node to visit
* @return the visited node
*/
- private ExprNode visitSimpleNode( SimpleNode node )
+ private ExprNode visitSimpleNode( SimpleNode node ) throws NamingException
{
// still need this check here in case the top level is a leaf node
// with an undefined attributeType for its attribute
@@ -212,17 +203,10 @@
return null;
}
- try
- {
- node.setAttribute( registries.getOidRegistry().getOid( node.getAttribute() ) );
- node.setValue( normalized );
- return node;
- }
- catch ( NamingException ne )
- {
- log.warn( "Failed to normalize filter node attribute: {}, error: {}", node.getAttribute(), ne.getMessage() );
- return null;
- }
+ node.setAttribute( schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute() ) );
+ node.setValue( normalized );
+
+ return node;
}
@@ -235,7 +219,7 @@
* @param node the node to visit
* @return the visited node
*/
- private ExprNode visitSubstringNode( SubstringNode node )
+ private ExprNode visitSubstringNode( SubstringNode node ) throws NamingException
{
// still need this check here in case the top level is a leaf node
// with an undefined attributeType for its attribute
@@ -290,37 +274,29 @@
}
}
- try
- {
- node.setAttribute( registries.getOidRegistry().getOid( node.getAttribute() ) );
+ node.setAttribute( schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute() ) );
- if ( normInitial != null )
- {
- node.setInitial( normInitial.getString() );
- }
- else
- {
- node.setInitial( null );
- }
-
- node.setAny( normAnys );
+ if ( normInitial != null )
+ {
+ node.setInitial( normInitial.getString() );
+ }
+ else
+ {
+ node.setInitial( null );
+ }
- if ( normFinal != null )
- {
- node.setFinal( normFinal.getString() );
- }
- else
- {
- node.setFinal( null );
- }
+ node.setAny( normAnys );
- return node;
+ if ( normFinal != null )
+ {
+ node.setFinal( normFinal.getString() );
}
- catch ( NamingException ne )
+ else
{
- log.warn( "Failed to normalize filter node attribute: {}, error: {}", node.getAttribute(), ne.getMessage() );
- return null;
+ node.setFinal( null );
}
+
+ return node;
}
@@ -333,18 +309,11 @@
* @param node the node to visit
* @return the visited node
*/
- private ExprNode visitExtensibleNode( ExtensibleNode node )
+ private ExprNode visitExtensibleNode( ExtensibleNode node ) throws NamingException
{
- try
- {
- node.setAttribute( registries.getOidRegistry().getOid( node.getAttribute() ) );
- return node;
- }
- catch ( NamingException ne )
- {
- log.warn( "Failed to normalize filter node attribute: {}, error: {}", node.getAttribute(), ne.getMessage() );
- return null;
- }
+ node.setAttribute( schemaManager.getAttributeTypeRegistry().getOidByName( node.getAttribute() ) );
+
+ return node;
}
@@ -459,47 +428,54 @@
* @param node the node to visit
* @return the visited node
*/
- public Object visit( ExprNode node )
+ public Object visit( ExprNode node )
{
- // -------------------------------------------------------------------
- // Handle PresenceNodes
- // -------------------------------------------------------------------
-
- if ( node instanceof PresenceNode )
- {
- return visitPresenceNode( ( PresenceNode ) node );
- }
-
- // -------------------------------------------------------------------
- // Handle BranchNodes (AndNode, NotNode and OrNode)
- // -------------------------------------------------------------------
-
- else if ( node instanceof BranchNode )
- {
- return visitBranchNode( ( BranchNode ) node );
- }
-
- // -------------------------------------------------------------------
- // Handle SimpleNodes (ApproximateNode, EqualityNode, GreaterEqNode,
- // and LesserEqNode)
- // -------------------------------------------------------------------
-
- else if ( node instanceof SimpleNode )
- {
- return visitSimpleNode( ( SimpleNode ) node );
- }
- else if ( node instanceof ExtensibleNode )
- {
- return visitExtensibleNode( ( ExtensibleNode ) node );
- }
- else if ( node instanceof SubstringNode )
- {
- return visitSubstringNode( ( SubstringNode ) node );
- }
- else
- {
- return null;
- }
+ try
+ {
+ // -------------------------------------------------------------------
+ // Handle PresenceNodes
+ // -------------------------------------------------------------------
+
+ if ( node instanceof PresenceNode )
+ {
+ return visitPresenceNode( ( PresenceNode ) node );
+ }
+
+ // -------------------------------------------------------------------
+ // Handle BranchNodes (AndNode, NotNode and OrNode)
+ // -------------------------------------------------------------------
+
+ else if ( node instanceof BranchNode )
+ {
+ return visitBranchNode( ( BranchNode ) node );
+ }
+
+ // -------------------------------------------------------------------
+ // Handle SimpleNodes (ApproximateNode, EqualityNode, GreaterEqNode,
+ // and LesserEqNode)
+ // -------------------------------------------------------------------
+
+ else if ( node instanceof SimpleNode )
+ {
+ return visitSimpleNode( ( SimpleNode ) node );
+ }
+ else if ( node instanceof ExtensibleNode )
+ {
+ return visitExtensibleNode( ( ExtensibleNode ) node );
+ }
+ else if ( node instanceof SubstringNode )
+ {
+ return visitSubstringNode( ( SubstringNode ) node );
+ }
+ else
+ {
+ return null;
+ }
+ }
+ catch( NamingException e )
+ {
+ throw new RuntimeException( e );
+ }
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java Wed Jan 6 18:26:43 2010
@@ -23,8 +23,8 @@
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.filtering.EntryFilteringCursor;
import org.apache.directory.server.core.filtering.BaseEntryFilteringCursor;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
import org.apache.directory.server.core.interceptor.BaseInterceptor;
import org.apache.directory.server.core.interceptor.NextInterceptor;
import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
@@ -43,29 +43,26 @@
import org.apache.directory.server.core.interceptor.context.RemoveContextPartitionOperationContext;
import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
-import org.apache.directory.server.core.partition.PartitionNexus;
-import org.apache.directory.server.schema.ConcreteNameComponentNormalizer;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
+import org.apache.directory.server.core.partition.DefaultPartitionNexus;
import org.apache.directory.shared.ldap.cursor.EmptyCursor;
+import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
+import org.apache.directory.shared.ldap.name.AVA;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
import org.apache.directory.shared.ldap.name.Rdn;
import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.normalizers.ConcreteNameComponentNormalizer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Map;
-
/**
* A name normalization service. This service makes sure all relative and distinguished
* names are normalized before calls are made against the respective interface methods
- * on {@link PartitionNexus}.
+ * on {@link DefaultPartitionNexus}.
*
* The Filters are also normalized.
*
@@ -85,11 +82,8 @@
/** a filter node value normalizer and undefined node remover */
private FilterNormalizingVisitor normVisitor;
- /** The association between attributeTypes and their normalizers */
- private Map<String, OidNormalizer> attrNormalizers;
-
- /** The globa attributeType registry */
- private AttributeTypeRegistry attributeRegistry;
+ /** The attributeType registry */
+ private SchemaManager schemaManager;
/**
* Initialize the registries, normalizers.
@@ -98,11 +92,9 @@
{
LOG.debug( "Initialiazing the NormalizationInterceptor" );
- OidRegistry oidRegistry = directoryService.getRegistries().getOidRegistry();
- attributeRegistry = directoryService.getRegistries().getAttributeTypeRegistry();
- NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( attributeRegistry, oidRegistry );
- normVisitor = new FilterNormalizingVisitor( ncn, directoryService.getRegistries() );
- attrNormalizers = attributeRegistry.getNormalizerMapping();
+ schemaManager = directoryService.getSchemaManager();
+ NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( schemaManager );
+ normVisitor = new FilterNormalizingVisitor( ncn, schemaManager );
}
/**
@@ -120,8 +112,8 @@
*/
public void add( NextInterceptor nextInterceptor, AddOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
- opContext.getEntry().getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
+ opContext.getEntry().getDn().normalize( schemaManager.getNormalizerMapping() );
addRdnAttributesToEntry( opContext.getDn(), opContext.getEntry() );
nextInterceptor.add( opContext );
}
@@ -132,7 +124,7 @@
*/
public void delete( NextInterceptor nextInterceptor, DeleteOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
nextInterceptor.delete( opContext );
}
@@ -142,7 +134,7 @@
*/
public void modify( NextInterceptor nextInterceptor, ModifyOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
nextInterceptor.modify( opContext );
}
@@ -152,12 +144,12 @@
*/
public void rename( NextInterceptor nextInterceptor, RenameOperationContext opContext ) throws Exception
{
- LdapDN rdn = new LdapDN();
- rdn.add( opContext.getNewRdn() );
- rdn.normalize( attrNormalizers );
- opContext.setNewRdn( rdn.getRdn() );
+ // Normalize the new RDN and the DN
+ opContext.getNewRdn().normalize( schemaManager.getNormalizerMapping() );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
+ opContext.getNewDn().normalize( schemaManager.getNormalizerMapping() );
- opContext.getDn().normalize( attrNormalizers );
+ // Push to the next interceptor
nextInterceptor.rename( opContext );
}
@@ -167,8 +159,8 @@
*/
public void move( NextInterceptor nextInterceptor, MoveOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
- opContext.getParent().normalize( attrNormalizers);
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
+ opContext.getParent().normalize( schemaManager.getNormalizerMapping());
nextInterceptor.move( opContext );
}
@@ -181,11 +173,11 @@
{
LdapDN rdn = new LdapDN();
rdn.add( opContext.getNewRdn() );
- rdn.normalize( attrNormalizers );
+ rdn.normalize( schemaManager.getNormalizerMapping() );
opContext.setNewRdn( rdn.getRdn() );
- opContext.getDn().normalize( attrNormalizers );
- opContext.getParent().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
+ opContext.getParent().normalize( schemaManager.getNormalizerMapping() );
nextInterceptor.moveAndRename( opContext );
}
@@ -195,7 +187,7 @@
*/
public EntryFilteringCursor search( NextInterceptor nextInterceptor, SearchOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
ExprNode filter = opContext.getFilter();
@@ -222,7 +214,7 @@
*/
public boolean hasEntry( NextInterceptor nextInterceptor, EntryOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
return nextInterceptor.hasEntry( opContext );
}
@@ -232,7 +224,7 @@
*/
public EntryFilteringCursor list( NextInterceptor nextInterceptor, ListOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
return nextInterceptor.list( opContext );
}
@@ -252,7 +244,7 @@
for ( String id:attrIds )
{
- String oid = attributeRegistry.lookup( id ).getOid();
+ String oid = schemaManager.lookupAttributeTypeRegistry( id ).getOid();
normalizedAttrIds[pos++] = oid;
}
@@ -265,7 +257,7 @@
*/
public ClonedServerEntry lookup( NextInterceptor nextInterceptor, LookupOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
if ( opContext.getAttrsId() != null )
{
@@ -285,7 +277,7 @@
*/
public LdapDN getMatchedName ( NextInterceptor nextInterceptor, GetMatchedNameOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
return nextInterceptor.getMatchedName( opContext );
}
@@ -295,7 +287,7 @@
*/
public LdapDN getSuffix ( NextInterceptor nextInterceptor, GetSuffixOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
return nextInterceptor.getSuffix( opContext );
}
@@ -305,9 +297,9 @@
*/
public boolean compare( NextInterceptor next, CompareOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
- AttributeType at = opContext.getSession().getDirectoryService().getRegistries().getAttributeTypeRegistry().lookup( opContext.getOid() );
+ AttributeType at = opContext.getSession().getDirectoryService().getSchemaManager().lookupAttributeTypeRegistry( opContext.getOid() );
if ( at.getSyntax().isHumanReadable() && ( opContext.getValue().isBinary() ) )
{
@@ -324,7 +316,7 @@
*/
public void bind( NextInterceptor next, BindOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
next.bind( opContext );
}
@@ -334,7 +326,7 @@
*/
public void addContextPartition( NextInterceptor next, AddContextPartitionOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
next.addContextPartition( opContext );
}
@@ -344,7 +336,7 @@
*/
public void removeContextPartition( NextInterceptor next, RemoveContextPartitionOperationContext opContext ) throws Exception
{
- opContext.getDn().normalize( attrNormalizers );
+ opContext.getDn().normalize( schemaManager.getNormalizerMapping() );
next.removeContextPartition( opContext );
}
@@ -365,10 +357,10 @@
Rdn rdn = dn.getRdn();
// Loop on all the AVAs
- for ( AttributeTypeAndValue ava : rdn )
+ for ( AVA ava : rdn )
{
- String value = ava.getNormValue().getString();
- String upValue = ava.getUpValue().getString();
+ Value<?> value = ava.getNormValue();
+ Value<?> upValue = ava.getUpValue();
String upId = ava.getUpType();
// Check that the entry contains this AVA
@@ -382,50 +374,27 @@
// 1) The attribute does not exist
if ( !entry.containsAttribute( upId ) )
{
- addUnescapedUpValue( entry, upId, upValue );
+ entry.add( upId, upValue );
}
// 2) The attribute exists
else
{
- AttributeType at = attributeRegistry.lookup( upId );
+ AttributeType at = schemaManager.lookupAttributeTypeRegistry( upId );
// 2.1 if the attribute is single valued, replace the value
- if ( at.isSingleValue() )
+ if ( at.isSingleValued() )
{
entry.removeAttributes( upId );
- addUnescapedUpValue( entry, upId, upValue );
+ entry.add( upId, upValue );
}
// 2.2 the attribute is multi-valued : add the missing value
else
{
- addUnescapedUpValue( entry, upId, upValue );
+ entry.add( upId, upValue );
}
}
}
}
}
-
- /**
- * Adds the user provided value to the given entry.
- * If the user provided value is string value it is unescaped first.
- * If the user provided value is a hex string the value is added as byte[].
- *
- * @param entry the entry
- * @param upId the user provided attribute type to add
- * @param upValue the user provided value to add
- */
- private void addUnescapedUpValue( ServerEntry entry, String upId, String upValue ) throws Exception
- {
- Object unescapedUpValue = Rdn.unescapeValue( upValue );
-
- if ( unescapedUpValue instanceof String )
- {
- entry.add( upId, ( String ) unescapedUpValue );
- }
- else
- {
- entry.add( upId, ( byte[] ) unescapedUpValue );
- }
- }
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java Wed Jan 6 18:26:43 2010
@@ -20,7 +20,6 @@
package org.apache.directory.server.core.operational;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -50,8 +49,6 @@
import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
import org.apache.directory.server.core.interceptor.context.SearchingOperationContext;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Modification;
@@ -59,10 +56,11 @@
import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
+import org.apache.directory.shared.ldap.name.AVA;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
import org.apache.directory.shared.ldap.schema.SchemaUtils;
import org.apache.directory.shared.ldap.schema.UsageEnum;
import org.apache.directory.shared.ldap.util.DateUtils;
@@ -114,16 +112,16 @@
};
- private AttributeTypeRegistry atRegistry;
-
private DirectoryService service;
private LdapDN subschemaSubentryDn;
- /** The registries */
- private Registries registries;
+ /** The schemaManager */
+ private SchemaManager schemaManager;
private static AttributeType CREATE_TIMESTAMP_ATTRIBUTE_TYPE;
+ private static AttributeType MODIFIERS_NAME_ATTRIBUTE_TYPE;
+ private static AttributeType MODIFY_TIMESTAMP_ATTRIBUTE_TYPE;
/**
@@ -137,16 +135,17 @@
public void init( DirectoryService directoryService ) throws Exception
{
service = directoryService;
- registries = directoryService.getRegistries();
- atRegistry = registries.getAttributeTypeRegistry();
+ schemaManager = directoryService.getSchemaManager();
// stuff for dealing with subentries (garbage for now)
Value<?> subschemaSubentry = service.getPartitionNexus()
.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
subschemaSubentryDn = new LdapDN( subschemaSubentry.getString() );
- subschemaSubentryDn.normalize( atRegistry.getNormalizerMapping() );
+ subschemaSubentryDn.normalize( schemaManager.getNormalizerMapping() );
- CREATE_TIMESTAMP_ATTRIBUTE_TYPE = atRegistry.lookup( SchemaConstants.CREATE_TIMESTAMP_AT );
+ CREATE_TIMESTAMP_ATTRIBUTE_TYPE = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.CREATE_TIMESTAMP_AT );
+ MODIFIERS_NAME_ATTRIBUTE_TYPE = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.MODIFIERS_NAME_AT );
+ MODIFY_TIMESTAMP_ATTRIBUTE_TYPE = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.MODIFY_TIMESTAMP_AT );
}
@@ -171,8 +170,9 @@
ServerEntry entry = opContext.getEntry();
- entry.put( SchemaConstants.CREATORS_NAME_AT, principal );
-
+ /*
+ * @TODO : This code was probably created while working on Mitosis. Most probably dead code. Commented.
+ * Check JIRA DIRSERVER-1416
if ( opContext.getEntry().containsAttribute( CREATE_TIMESTAMP_ATTRIBUTE_TYPE ) )
{
// As we already have a CreateTimeStamp value in the context, use it, but only if
@@ -193,11 +193,50 @@
{
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
}
+ */
// Add the UUID and the entryCSN. The UUID is stored as a byte[] representation of
// its String value
- entry.put( SchemaConstants.ENTRY_UUID_AT, SchemaUtils.uuidToBytes( UUID.randomUUID() ) );
- entry.put( SchemaConstants.ENTRY_CSN_AT, service.getCSN().toString() );
+ // @TODO : If we are using replication, those four OAs may be already present.
+ // We have to deal with this as soon as we have the replication working again
+
+ // Check that we don't have an entryUUID AT in the incoming entry, as it's a NO-USER-MODIFICATION AT
+ // Of course, we will allow if for replication (see above @TODO)
+ boolean isAdmin = opContext.getSession().getAuthenticatedPrincipal().getName().equals(
+ ServerDNConstants.ADMIN_SYSTEM_DN_NORMALIZED );
+
+ if ( entry.containsAttribute( SchemaConstants.ENTRY_UUID_AT ) )
+ {
+ if ( !isAdmin )
+ {
+ // Wrong !
+ String message = "The " + SchemaConstants.ENTRY_UUID_AT + " operational attribute cannot be modified by a user";
+ LOG.error( message );
+ throw new LdapSchemaViolationException( message, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
+ }
+ }
+ else
+ {
+ entry.put( SchemaConstants.ENTRY_UUID_AT, SchemaUtils.uuidToBytes( UUID.randomUUID() ) );
+ }
+
+ if ( entry.containsAttribute( SchemaConstants.ENTRY_CSN_AT ) )
+ {
+ if ( !isAdmin )
+ {
+ // Wrong !
+ String message = "The " + SchemaConstants.ENTRY_CSN_AT + " operational attribute cannot be modified by a user";
+ LOG.error( message );
+ throw new LdapSchemaViolationException( message, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
+ }
+ }
+ else
+ {
+ entry.put( SchemaConstants.ENTRY_CSN_AT, service.getCSN().toString() );
+ }
+
+ entry.put( SchemaConstants.CREATORS_NAME_AT, principal );
+ entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
nextInterceptor.add( opContext );
}
@@ -206,6 +245,51 @@
public void modify( NextInterceptor nextInterceptor, ModifyOperationContext opContext )
throws Exception
{
+ // We must check that the user hasn't injected either the modifiersName
+ // or the modifyTimestamp operational attributes : they are not supposed to be
+ // added at this point.
+ // If so, remove them, and if there are no more attributes, simply return.
+ // otherwise, inject those values into the list of modifications
+ List<Modification> mods = opContext.getModItems();
+
+ for ( Modification modification: mods )
+ {
+ AttributeType attributeType = ((ServerAttribute)modification.getAttribute()).getAttributeType();
+
+ if ( attributeType.equals( MODIFIERS_NAME_ATTRIBUTE_TYPE ) )
+ {
+ String message = "The ModifiersName operational attribute cannot be modified by a user";
+ LOG.error( message );
+ throw new LdapSchemaViolationException( message, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
+ }
+
+ if ( attributeType.equals( MODIFY_TIMESTAMP_ATTRIBUTE_TYPE ) )
+ {
+ String message = "The ModifyTimestamp operational attribute cannot be modified by a user";
+ LOG.error( message );
+ throw new LdapSchemaViolationException( message, ResultCodeEnum.INSUFFICIENT_ACCESS_RIGHTS );
+ }
+ }
+
+ // Inject the ModifiersName AT if it's not present
+ ServerAttribute attribute = new DefaultServerAttribute(
+ MODIFIERS_NAME_ATTRIBUTE_TYPE,
+ getPrincipal().getName());
+
+ Modification modifiersName = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );
+
+ mods.add( modifiersName );
+
+ // Inject the ModifyTimestamp AT if it's not present
+ attribute = new DefaultServerAttribute(
+ MODIFY_TIMESTAMP_ATTRIBUTE_TYPE,
+ DateUtils.getGeneralizedTime() );
+
+ Modification timestamp = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );
+
+ mods.add( timestamp );
+
+ // Go down in the chain
nextInterceptor.modify( opContext );
if ( opContext.getDn().getNormName().equals( subschemaSubentryDn.getNormName() ) )
@@ -216,36 +300,35 @@
// -------------------------------------------------------------------
// Add the operational attributes for the modifier first
// -------------------------------------------------------------------
-
+ // TODO : Why can't we add those elements on teh original modifications ???
+ // Or into the context ?
+ /*
List<Modification> modItemList = new ArrayList<Modification>(2);
AttributeType modifiersNameAt = atRegistry.lookup( SchemaConstants.MODIFIERS_NAME_AT );
ServerAttribute attribute = new DefaultServerAttribute(
- SchemaConstants.MODIFIERS_NAME_AT,
modifiersNameAt,
getPrincipal().getName());
Modification modifiers = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );
- //modifiers.setServerModified();
modItemList.add( modifiers );
AttributeType modifyTimeStampAt = atRegistry.lookup( SchemaConstants.MODIFY_TIMESTAMP_AT );
attribute = new DefaultServerAttribute(
- SchemaConstants.MODIFY_TIMESTAMP_AT,
modifyTimeStampAt,
DateUtils.getGeneralizedTime() );
Modification timestamp = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute );
- //timestamp.setServerModified();
modItemList.add( timestamp );
// -------------------------------------------------------------------
// Make the modify() call happen
// -------------------------------------------------------------------
-
ModifyOperationContext newModify = new ModifyOperationContext( opContext.getSession(),
opContext.getDn(), modItemList );
+ newModify.setEntry( opContext.getAlteredEntry() );
service.getPartitionNexus().modify( newModify );
+ */
}
@@ -254,19 +337,17 @@
{
nextInterceptor.rename( opContext );
+ LdapDN newDn = opContext.getNewDn();
+
// add operational attributes after call in case the operation fails
- ServerEntry serverEntry = new DefaultServerEntry( registries, opContext.getDn() );
+ ServerEntry serverEntry = new DefaultServerEntry( schemaManager, newDn );
serverEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
serverEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
- LdapDN newDn = ( LdapDN ) opContext.getDn().clone();
- newDn.remove( opContext.getDn().size() - 1 );
- newDn.add( opContext.getNewRdn() );
- newDn.normalize( atRegistry.getNormalizerMapping() );
-
List<Modification> items = ModifyOperationContext.createModItems( serverEntry, ModificationOperation.REPLACE_ATTRIBUTE );
ModifyOperationContext newModify = new ModifyOperationContext( opContext.getSession(), newDn, items );
+ newModify.setEntry( opContext.getAlteredEntry() );
service.getPartitionNexus().modify( newModify );
}
@@ -277,7 +358,7 @@
nextInterceptor.move( opContext );
// add operational attributes after call in case the operation fails
- ServerEntry serverEntry = new DefaultServerEntry( registries, opContext.getDn() );
+ ServerEntry serverEntry = new DefaultServerEntry( schemaManager, opContext.getDn() );
serverEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
serverEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
@@ -297,7 +378,7 @@
nextInterceptor.moveAndRename( opContext );
// add operational attributes after call in case the operation fails
- ServerEntry serverEntry = new DefaultServerEntry( registries, opContext.getDn() );
+ ServerEntry serverEntry = new DefaultServerEntry( schemaManager, opContext.getDn() );
serverEntry.put( SchemaConstants.MODIFIERS_NAME_AT, getPrincipal().getName() );
serverEntry.put( SchemaConstants.MODIFY_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
@@ -436,7 +517,7 @@
LdapDN creatorsName = new LdapDN( attr.getString() );
attr.clear();
- attr.add( denormalizeTypes( creatorsName ).getUpName() );
+ attr.add( denormalizeTypes( creatorsName ).getName() );
}
attr = entry.get( SchemaConstants.MODIFIERS_NAME_AT );
@@ -446,7 +527,7 @@
LdapDN modifiersName = new LdapDN( attr.getString() );
attr.clear();
- attr.add( denormalizeTypes( modifiersName ).getUpName() );
+ attr.add( denormalizeTypes( modifiersName ).getName() );
}
attr = entry.get( ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT );
@@ -456,7 +537,7 @@
LdapDN modifiersName = new LdapDN( attr.getString() );
attr.clear();
- attr.add( denormalizeTypes( modifiersName ).getUpName() );
+ attr.add( denormalizeTypes( modifiersName ).getName() );
}
}
}
@@ -484,7 +565,7 @@
}
else if ( rdn.size() == 1 )
{
- String name = atRegistry.lookup( rdn.getNormType() ).getName();
+ String name = schemaManager.lookupAttributeTypeRegistry( rdn.getNormType() ).getName();
String value = rdn.getAtav().getNormValue().getString();
newDn.add( new Rdn( name, name, value, value ) );
continue;
@@ -493,10 +574,10 @@
// below we only process multi-valued rdns
StringBuffer buf = new StringBuffer();
- for ( Iterator<AttributeTypeAndValue> atavs = rdn.iterator(); atavs.hasNext(); /**/ )
+ for ( Iterator<AVA> atavs = rdn.iterator(); atavs.hasNext(); /**/ )
{
- AttributeTypeAndValue atav = atavs.next();
- String type = atRegistry.lookup( rdn.getNormType() ).getName();
+ AVA atav = atavs.next();
+ String type = schemaManager.lookupAttributeTypeRegistry( rdn.getNormType() ).getName();
buf.append( type ).append( '=' ).append( atav.getNormValue() );
if ( atavs.hasNext() )
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java Wed Jan 6 18:26:43 2010
@@ -20,11 +20,20 @@
package org.apache.directory.server.core.partition.impl.btree;
+import java.io.File;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import javax.naming.InvalidNameException;
+import javax.naming.directory.SearchControls;
+
import org.apache.directory.server.constants.ApacheSchemaConstants;
import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.filtering.EntryFilteringCursor;
import org.apache.directory.server.core.filtering.BaseEntryFilteringCursor;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
import org.apache.directory.server.core.interceptor.context.AddOperationContext;
import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
import org.apache.directory.server.core.interceptor.context.EntryOperationContext;
@@ -37,21 +46,15 @@
import org.apache.directory.server.core.interceptor.context.SearchOperationContext;
import org.apache.directory.server.core.partition.Partition;
import org.apache.directory.server.core.partition.impl.btree.gui.PartitionViewer;
-import org.apache.directory.server.schema.registries.Registries;
-import org.apache.directory.server.xdbm.*;
+import org.apache.directory.server.xdbm.Index;
+import org.apache.directory.server.xdbm.IndexCursor;
import org.apache.directory.server.xdbm.search.Optimizer;
import org.apache.directory.server.xdbm.search.SearchEngine;
-import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.exception.LdapContextNotEmptyException;
import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.schema.AttributeType;
-
-import javax.naming.directory.SearchControls;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
/**
@@ -84,15 +87,16 @@
protected SearchEngine<ServerEntry> searchEngine;
protected Optimizer optimizer;
- protected Registries registries;
+ protected SchemaManager schemaManager;
protected String id;
protected int cacheSize = -1;
- protected LdapDN suffixDn;
- protected String suffix;
+ protected LdapDN suffix;
+ private File partitionDir;
/** The rootDSE context */
protected ServerEntry contextEntry;
+ private Set<Index<?,ServerEntry>> indexedAttributes;
// ------------------------------------------------------------------------
@@ -105,6 +109,7 @@
*/
protected BTreePartition()
{
+ indexedAttributes = new HashSet<Index<?,ServerEntry>>();
}
@@ -114,6 +119,67 @@
/**
+ * {@inheritDoc}
+ */
+ public void setSchemaManager( SchemaManager schemaManager )
+ {
+ this.schemaManager = schemaManager;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public SchemaManager getSchemaManager()
+ {
+ return schemaManager;
+ }
+
+
+ /**
+ * Gets the directory in which this Partition stores files.
+ *
+ * @return the directory in which this Partition stores files.
+ */
+ public File getPartitionDir()
+ {
+ return partitionDir;
+ }
+
+
+ /**
+ * Sets the directory in which this Partition stores files.
+ *
+ * @param partitionDir the directory in which this Partition stores files.
+ */
+ public void setPartitionDir( File partitionDir )
+ {
+ this.partitionDir = partitionDir;
+ }
+
+
+ public void setIndexedAttributes( Set<Index<?,ServerEntry>> indexedAttributes )
+ {
+ this.indexedAttributes = indexedAttributes;
+ }
+
+
+ public void addIndexedAttributes( Index<?,ServerEntry>... indexes )
+ {
+ for ( Index<?,ServerEntry> index : indexes )
+ {
+ indexedAttributes.add( index );
+ }
+ }
+
+
+ public Set<Index<?,ServerEntry>> getIndexedAttributes()
+ {
+ return indexedAttributes;
+ }
+
+
+ /**
* Used to specify the entry cache size for a Partition. Various Partition
* implementations may interpret this value in different ways: i.e. total cache
* size limit verses the number of entries to cache.
@@ -164,19 +230,6 @@
// -----------------------------------------------------------------------
- /**
- * Allows for schema entity registries to be swapped out during runtime. This is
- * primarily here to facilitate the swap out of a temporary bootstrap registry.
- * Registry changes require swapping out the search engine used by a partition
- * since the registries are used by elements in the search engine.
- *
- * @org.apache.xbean.Property hidden="true"
- * @param registries the schema entity registries
- * @throws Exception
- */
- public abstract void setRegistries( Registries registries ) throws Exception;
-
-
// ------------------------------------------------------------------------
// Public Accessors - not declared in any interfaces just for this class
// ------------------------------------------------------------------------
@@ -198,6 +251,9 @@
// ------------------------------------------------------------------------
+ /**
+ * {@inheritDoc}
+ */
public void delete( DeleteOperationContext opContext ) throws Exception
{
LdapDN dn = opContext.getDn();
@@ -304,7 +360,7 @@
public void inspect() throws Exception
{
- PartitionViewer viewer = new PartitionViewer( this, registries );
+ PartitionViewer viewer = new PartitionViewer( this, schemaManager );
viewer.execute();
}
@@ -472,9 +528,9 @@
/**
* {@inheritDoc}
*/
- public void setSuffix( String suffix )
+ public void setSuffix( String suffix ) throws InvalidNameException
{
- this.suffix = suffix;
+ this.suffix = new LdapDN( suffix );
}
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AddEntryDialog.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AddEntryDialog.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AddEntryDialog.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/AddEntryDialog.java Wed Jan 6 18:26:43 2010
@@ -41,8 +41,8 @@
import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -82,10 +82,10 @@
* @param parent the parent frame
* @param modal whether or not to go modal on the dialog
*/
- public AddEntryDialog(Frame parent, boolean modal, Registries registries )
+ public AddEntryDialog(Frame parent, boolean modal, SchemaManager schemaManager )
{
super( parent, modal );
- childEntry = new DefaultServerEntry( registries );
+ childEntry = new DefaultServerEntry( schemaManager );
childEntry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC );
initGUI();
}