You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2008/05/01 02:06:46 UTC
svn commit: r652410 [13/14] - in /directory: apacheds/branches/bigbang/
apacheds/branches/bigbang/apacheds-jdbm/
apacheds/branches/bigbang/apacheds-jdbm/src/
apacheds/branches/bigbang/apacheds-jdbm/src/etc/
apacheds/branches/bigbang/apacheds-jdbm/src/e...
Modified: directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/SocketAcceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/SocketAcceptor.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/SocketAcceptor.java (original)
+++ directory/apacheds/branches/bigbang/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/SocketAcceptor.java Wed Apr 30 17:06:41 2008
@@ -41,19 +41,16 @@
public SocketAcceptor( Executor logicExecutor )
{
- super( Runtime.getRuntime().availableProcessors(), getIOExecutor());
+ super( Runtime.getRuntime().availableProcessors(), Executors.newCachedThreadPool());
+
if ( logicExecutor == null )
{
logicExecutor = Executors.newFixedThreadPool( DEFAULT_THREADS );
}
+
getFilterChain().addLast( "executor", new ExecutorFilter( logicExecutor ) );
}
- private static Executor getIOExecutor()
- {
- return Executors.newCachedThreadPool();
- }
-
public void bind( SocketAddress address, IoHandler ioHandler, IoServiceConfig tcpConfig ) throws IOException
{
tcpConfig.setThreadModel( ThreadModel.MANUAL );
@@ -64,6 +61,4 @@
{
super.unbind(address);
}
-
-
}
Modified: directory/apacheds/branches/bigbang/schema-bootstrap/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/schema-bootstrap/pom.xml?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/schema-bootstrap/pom.xml (original)
+++ directory/apacheds/branches/bigbang/schema-bootstrap/pom.xml Wed Apr 30 17:06:41 2008
@@ -56,8 +56,9 @@
</dependency>
<dependency>
- <groupId>jdbm</groupId>
- <artifactId>jdbm</artifactId>
+ <groupId>${pom.groupId}</groupId>
+ <version>${pom.version}</version>
+ <artifactId>apacheds-jdbm</artifactId>
</dependency>
</dependencies>
Modified: directory/apacheds/branches/bigbang/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java (original)
+++ directory/apacheds/branches/bigbang/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java Wed Apr 30 17:06:41 2008
@@ -137,9 +137,9 @@
HashMap<String,Schema> loaded = new HashMap<String,Schema>();
HashMap<String,Schema> notLoaded = new HashMap<String,Schema>();
- for ( int ii = 0; ii < schemas.length; ii++ )
+ for ( BootstrapSchema schema:schemas )
{
- notLoaded.put( schemas[ii].getSchemaName(), schemas[ii] );
+ notLoaded.put( schema.getSchemaName(), schema );
}
BootstrapSchema schema;
Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java (original)
+++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java Wed Apr 30 17:06:41 2008
@@ -243,7 +243,7 @@
base.disableTransactions();
CacheRecordManager recMan = new CacheRecordManager( base, new MRU( 1000 ) );
- JdbmMasterTable master = new JdbmMasterTable( recMan );
+ JdbmMasterTable master = new JdbmMasterTable( recMan, bootstrapRegistries );
AttributeType attributeType = bootstrapRegistries.getAttributeTypeRegistry().lookup( "apacheUpdn" );
JdbmIndex idIndex = new JdbmIndex();
idIndex.setAttributeId( attributeType.getName() );
Modified: directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/IndexCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/IndexCommand.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/IndexCommand.java (original)
+++ directory/apacheds/branches/bigbang/server-tools/src/main/java/org/apache/directory/server/tools/IndexCommand.java Wed Apr 30 17:06:41 2008
@@ -207,7 +207,7 @@
base.disableTransactions();
CacheRecordManager recMan = new CacheRecordManager( base, new MRU( 1000 ) );
- JdbmMasterTable master = new JdbmMasterTable( recMan );
+ JdbmMasterTable master = new JdbmMasterTable( recMan, bootstrapRegistries );
JdbmIndex index = new JdbmIndex();
index.setAttributeId( attributeType.getName() );
index.setWkDirPath( partitionDirectory );
Modified: directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java (original)
+++ directory/apacheds/branches/bigbang/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java Wed Apr 30 17:06:41 2008
@@ -121,7 +121,7 @@
/**
* Just a little test to check wether opening the connection succeeds.
- */
+ *
@Test public void testSetUpTearDown()
{
assertNotNull( ctx );
@@ -132,7 +132,7 @@
* Modify Rdn of an entry, delete its old rdn value.
*
* @throws NamingException
- */
+ *
@Test public void testModifyRdnAndDeleteOld() throws NamingException
{
// Create a person, cn value is rdn
@@ -179,7 +179,7 @@
* The JNDI property is set with 'False'
*
* @throws NamingException
- */
+ *
@Test public void testModifyRdnAndDontDeleteOldFalse() throws NamingException
{
// Create a person, cn value is rdn
@@ -224,7 +224,7 @@
* Modify Rdn of an entry, keep its old rdn value.
*
* @throws NamingException
- */
+ *
@Test public void testModifyRdnAndKeepOld() throws NamingException
{
// Create a person, cn value is rdn
@@ -271,7 +271,7 @@
* cn has another value as well.
*
* @throws NamingException
- */
+ *
@Test public void testModifyRdnAndDeleteOldVariant() throws NamingException
{
// Create a person, cn value is rdn
@@ -325,7 +325,7 @@
* Modify DN of an entry, changing RDN from cn to sn.
*
* @throws NamingException
- */
+ *
@Test public void testModifyRdnDifferentAttribute() throws NamingException
{
@@ -447,7 +447,7 @@
* Ensure that the attribute itself contains the not-escaped value.
*
* @throws Exception
- */
+ *
@Test
public void testModifyRdnWithEncodedNewRdn() throws Exception
{
@@ -490,6 +490,6 @@
// Remove entry (use new rdn)
ctx.unbind( newRdn );
}
-
+*/
}
Modified: directory/apacheds/branches/bigbang/utils/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/utils/pom.xml?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/utils/pom.xml (original)
+++ directory/apacheds/branches/bigbang/utils/pom.xml Wed Apr 30 17:06:41 2008
@@ -46,6 +46,12 @@
<artifactId>apacheds-core-shared</artifactId>
<version>${pom.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>${pom.groupId}</groupId>
+ <artifactId>apacheds-core-entry</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
</dependencies>
</project>
Modified: directory/apacheds/branches/bigbang/utils/src/main/java/org/apache/directory/server/utils/AttributesFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/utils/src/main/java/org/apache/directory/server/utils/AttributesFactory.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/utils/src/main/java/org/apache/directory/server/utils/AttributesFactory.java (original)
+++ directory/apacheds/branches/bigbang/utils/src/main/java/org/apache/directory/server/utils/AttributesFactory.java Wed Apr 30 17:06:41 2008
@@ -23,14 +23,15 @@
import java.util.Comparator;
import javax.naming.NamingException;
-import javax.naming.directory.Attribute;
-import javax.naming.directory.Attributes;
import org.apache.directory.server.constants.MetaSchemaConstants;
+import org.apache.directory.server.core.entry.DefaultServerAttribute;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.schema.bootstrap.Schema;
+import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.message.AttributeImpl;
-import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.schema.AttributeType;
import org.apache.directory.shared.ldap.schema.DITContentRule;
import org.apache.directory.shared.ldap.schema.DITStructureRule;
@@ -54,49 +55,50 @@
*/
public class AttributesFactory
{
- public Attributes getAttributes( SchemaObject obj, Schema schema ) throws NamingException
+ public ServerEntry getAttributes( SchemaObject obj, Schema schema, Registries registries ) throws NamingException
{
if ( obj instanceof Syntax )
{
- return getAttributes( ( Syntax ) obj, schema );
+ return getAttributes( ( Syntax ) obj, schema, registries );
}
else if ( obj instanceof MatchingRule )
{
- return getAttributes( ( MatchingRule ) obj, schema );
+ return getAttributes( ( MatchingRule ) obj, schema, registries );
}
else if ( obj instanceof AttributeType )
{
- return getAttributes( ( AttributeType ) obj, schema );
+ return getAttributes( ( AttributeType ) obj, schema, registries );
}
else if ( obj instanceof ObjectClass )
{
- return getAttributes( ( ObjectClass ) obj, schema );
+ return getAttributes( ( ObjectClass ) obj, schema, registries );
}
else if ( obj instanceof MatchingRuleUse )
{
- return getAttributes( ( MatchingRuleUse ) obj, schema );
+ return getAttributes( ( MatchingRuleUse ) obj, schema, registries );
}
else if ( obj instanceof DITStructureRule )
{
- return getAttributes( ( DITStructureRule ) obj, schema );
+ return getAttributes( ( DITStructureRule ) obj, schema, registries );
}
else if ( obj instanceof DITContentRule )
{
- return getAttributes( ( DITContentRule ) obj, schema );
+ return getAttributes( ( DITContentRule ) obj, schema, registries );
}
else if ( obj instanceof NameForm )
{
- return getAttributes( ( NameForm ) obj, schema );
+ return getAttributes( ( NameForm ) obj, schema, registries );
}
throw new IllegalArgumentException( "Unknown SchemaObject type: " + obj.getClass() );
}
- public Attributes getAttributes( Schema schema )
+ public ServerEntry getAttributes( Schema schema, Registries registries ) throws NamingException
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_SCHEMA_OC );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SCHEMA_OC );
entry.put( SchemaConstants.CN_AT, schema.getSchemaName() );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
@@ -107,13 +109,16 @@
}
String[] dependencies = schema.getDependencies();
+
if ( dependencies != null && dependencies.length > 0 )
{
- Attribute attr = new AttributeImpl( MetaSchemaConstants.M_DEPENDENCIES_AT );
- for ( int ii = 0; ii < dependencies.length; ii++ )
+ EntryAttribute attr = new DefaultServerAttribute( registries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_DEPENDENCIES_AT ) );
+
+ for ( String dependency:dependencies )
{
- attr.add( dependencies[ii] );
+ attr.add( dependency );
}
+
entry.put( attr );
}
@@ -121,34 +126,39 @@
}
- public Attributes getAttributes( SyntaxChecker syntaxChecker, Schema schema )
+ public ServerEntry getAttributes( SyntaxChecker syntaxChecker, Schema schema, Registries registries )
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_SYNTAX_CHECKER_OC );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SYNTAX_CHECKER_OC );
entry.put( MetaSchemaConstants.M_OID_AT, syntaxChecker.getSyntaxOid() );
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 Attributes getAttributes( Syntax syntax, Schema schema )
+ public ServerEntry getAttributes( Syntax syntax, Schema schema, Registries registries ) throws NamingException
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_SYNTAX_OC );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_SYNTAX_OC );
entry.put( MetaSchemaConstants.X_HUMAN_READABLE_AT, getBoolean( syntax.isHumanReadable() ) );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
- injectCommon( syntax, entry );
+ injectCommon( syntax, entry, registries );
+
return entry;
}
- public Attributes getAttributes( String oid, Normalizer normalizer, Schema schema )
+ public ServerEntry getAttributes( String oid, Normalizer normalizer, Schema schema, Registries registries )
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_NORMALIZER_OC );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_NORMALIZER_OC );
entry.put( MetaSchemaConstants.M_OID_AT, oid );
entry.put( MetaSchemaConstants.M_FQCN_AT, normalizer.getClass().getName() );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
@@ -157,10 +167,11 @@
}
- public Attributes getAttributes( String oid, Comparator comparator, Schema schema )
+ public ServerEntry getAttributes( String oid, Comparator comparator, Schema schema, Registries registries )
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_COMPARATOR_OC );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_COMPARATOR_OC );
entry.put( MetaSchemaConstants.M_OID_AT, oid );
entry.put( MetaSchemaConstants.M_FQCN_AT, comparator.getClass().getName() );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
@@ -175,52 +186,57 @@
* @return Attributes
* @throws NamingException
*/
- public Attributes getAttributes( MatchingRule matchingRule, Schema schema ) throws NamingException
+ public ServerEntry getAttributes( MatchingRule matchingRule, Schema schema, Registries registries ) throws NamingException
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_MATCHING_RULE_OC );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_MATCHING_RULE_OC );
entry.put( MetaSchemaConstants.M_SYNTAX_AT, matchingRule.getSyntax().getOid() );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
- injectCommon( matchingRule, entry );
+ injectCommon( matchingRule, entry, registries );
return entry;
}
- public Attributes getAttributes( MatchingRuleUse matchingRuleUse, Schema schema )
+ public ServerEntry getAttributes( MatchingRuleUse matchingRuleUse, Schema schema, Registries registries )
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( "" );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, "" );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
return entry;
}
- public Attributes getAttributes( DITStructureRule dITStructureRule, Schema schema )
+ public ServerEntry getAttributes( DITStructureRule dITStructureRule, Schema schema, Registries registries )
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( "" );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, "" );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
return entry;
}
- public Attributes getAttributes( DITContentRule dITContentRule, Schema schema )
+ public ServerEntry getAttributes( DITContentRule dITContentRule, Schema schema, Registries registries )
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( "" );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, "" );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
return entry;
}
- public Attributes getAttributes( NameForm nameForm, Schema schema )
+ public ServerEntry getAttributes( NameForm nameForm, Schema schema, Registries registries )
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( "" );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, "" );
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
return entry;
@@ -245,10 +261,11 @@
* @return Attributes
* @throws NamingException
*/
- public Attributes getAttributes( AttributeType attributeType, Schema schema ) throws NamingException
+ public ServerEntry getAttributes( AttributeType attributeType, Schema schema, Registries registries ) throws NamingException
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC );
entry.put( MetaSchemaConstants.M_SYNTAX_AT, attributeType.getSyntax().getOid() );
entry.put( MetaSchemaConstants.M_COLLECTIVE_AT, getBoolean( attributeType.isCollective() ) );
entry.put( MetaSchemaConstants.M_NO_USER_MODIFICATION_AT, getBoolean( ! attributeType.isCanUserModify() ) );
@@ -257,17 +274,20 @@
entry.put( SchemaConstants.CREATORS_NAME_AT, schema.getOwner() );
entry.put( SchemaConstants.CREATE_TIMESTAMP_AT, DateUtils.getGeneralizedTime() );
- injectCommon( attributeType, entry );
+ injectCommon( attributeType, entry, registries );
AttributeType superior = attributeType.getSuperior();
+
if ( superior != null )
{
// use name if we can for clarity
String sup = superior.getName();
+
if ( sup == null )
{
sup = superior.getOid();
}
+
entry.put( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT, sup );
}
@@ -330,49 +350,56 @@
* @return the attributes of the metaSchema entry representing the objectClass
* @throws NamingException if there are any problems
*/
- public Attributes getAttributes( ObjectClass objectClass, Schema schema ) throws NamingException
+ public ServerEntry getAttributes( ObjectClass objectClass, Schema schema, Registries registries ) throws NamingException
{
- Attributes entry = new AttributesImpl( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true );
- entry.get( SchemaConstants.OBJECT_CLASS_AT ).add( MetaSchemaConstants.META_OBJECT_CLASS_OC );
+ ServerEntry entry = new DefaultServerEntry( registries );
+
+ entry.put( SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, MetaSchemaConstants.META_OBJECT_CLASS_OC );
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 );
+ injectCommon( objectClass, entry, registries );
// handle the superior objectClasses
if ( objectClass.getSuperClasses() != null && objectClass.getSuperClasses().length != 0 )
{
- Attribute attr = new AttributeImpl( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT );
- ObjectClass[] superclasses = objectClass.getSuperClasses();
- for ( int ii = 0; ii < superclasses.length; ii++ )
+ EntryAttribute attr = new DefaultServerAttribute( registries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT ) );
+ ObjectClass[] superClasses = objectClass.getSuperClasses();
+
+ for ( ObjectClass superClass:superClasses )
{
- attr.add( getNameOrNumericoid( superclasses[ii] ) );
+ attr.add( getNameOrNumericoid( superClass ) );
}
+
entry.put( attr );
}
// add the must list
if ( objectClass.getMustList() != null && objectClass.getMustList().length != 0 )
{
- Attribute attr = new AttributeImpl( MetaSchemaConstants.M_MUST_AT );
+ EntryAttribute attr = new DefaultServerAttribute( registries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_MUST_AT ) );
AttributeType[] mustList = objectClass.getMustList();
- for ( int ii = 0; ii < mustList.length; ii++ )
+
+ for ( AttributeType attributeType:mustList )
{
- attr.add( getNameOrNumericoid( mustList[ii] ) );
+ attr.add( getNameOrNumericoid( attributeType ) );
}
+
entry.put( attr );
}
// add the may list
if ( objectClass.getMayList() != null && objectClass.getMayList().length != 0 )
{
- Attribute attr = new AttributeImpl( MetaSchemaConstants.M_MAY_AT );
+ EntryAttribute attr = new DefaultServerAttribute( registries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_MAY_AT ) );
AttributeType[] mayList = objectClass.getMayList();
- for ( int ii = 0; ii < mayList.length; ii++ )
+
+ for ( AttributeType attributeType:mayList )
{
- attr.add( getNameOrNumericoid( mayList[ii] ) );
+ attr.add( getNameOrNumericoid( attributeType ) );
}
+
entry.put( attr );
}
@@ -382,7 +409,7 @@
private final String getNameOrNumericoid( SchemaObject object )
{
- // first try to use userfriendly name if we can
+ // first try to use user friendly name if we can
if ( object.getName() != null )
{
return object.getName();
@@ -392,9 +419,9 @@
}
- private final void injectCommon( SchemaObject object, Attributes entry )
+ private final void injectCommon( SchemaObject object, ServerEntry entry, Registries registries ) throws NamingException
{
- injectNames( object.getNames(), entry );
+ injectNames( object.getNames(), entry, registries );
entry.put( MetaSchemaConstants.M_OBSOLETE_AT, getBoolean( object.isObsolete() ) );
entry.put( MetaSchemaConstants.M_OID_AT, object.getOid() );
@@ -405,18 +432,20 @@
}
- private final void injectNames( String[] names, Attributes entry )
+ private final void injectNames( String[] names, ServerEntry entry, Registries registries ) throws NamingException
{
if ( names == null || names.length == 0 )
{
return;
}
- Attribute attr = new AttributeImpl( MetaSchemaConstants.M_NAME_AT );
- for ( int ii = 0; ii < names.length; ii++ )
+ EntryAttribute attr = new DefaultServerAttribute( registries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_NAME_AT ) );
+
+ for ( String name:names )
{
- attr.add( names[ii] );
+ attr.add( name );
}
+
entry.put( attr );
}
Modified: directory/shared/branches/bigbang/ldap/src/main/antlr/ACIItem.g
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/antlr/ACIItem.g?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/antlr/ACIItem.g (original)
+++ directory/shared/branches/bigbang/ldap/src/main/antlr/ACIItem.g Wed Apr 30 17:06:41 2008
@@ -55,6 +55,7 @@
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
import org.apache.directory.shared.ldap.schema.OidNormalizer;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -1223,7 +1224,7 @@
:
ID_item ( SP )* COLON ( SP )* oid=oid
{
- node = new EqualityNode( SchemaConstants.OBJECT_CLASS_AT , oid );
+ node = new EqualityNode( SchemaConstants.OBJECT_CLASS_AT , new ClientStringValue( oid ) );
}
;
Modified: directory/shared/branches/bigbang/ldap/src/main/antlr/subtree-specification.g
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/antlr/subtree-specification.g?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/antlr/subtree-specification.g (original)
+++ directory/shared/branches/bigbang/ldap/src/main/antlr/subtree-specification.g Wed Apr 30 17:06:41 2008
@@ -45,6 +45,7 @@
import org.apache.directory.shared.ldap.util.ComponentsMonitor;
import org.apache.directory.shared.ldap.util.OptionalComponentsMonitor;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -398,7 +399,7 @@
:
ID_item ( SP )* COLON ( SP )* oid=oid
{
- node = new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, oid );
+ node = new EqualityNode( SchemaConstants.OBJECT_CLASS_AT, new ClientStringValue( oid ) );
}
;
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/AttributeValueAssertion.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/AttributeValueAssertion.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/AttributeValueAssertion.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/AttributeValueAssertion.java Wed Apr 30 17:06:41 2008
@@ -19,6 +19,7 @@
*/
package org.apache.directory.shared.ldap.codec;
+import org.apache.directory.shared.ldap.entry.Value;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -45,7 +46,7 @@
private String attributeDesc;
/** The assertion value */
- private Object assertionValue;
+ private Value<?> assertionValue;
// ~ Methods
@@ -56,7 +57,7 @@
*
* @return Returns the assertionValue.
*/
- public Object getAssertionValue()
+ public Value<?> getAssertionValue()
{
return assertionValue;
}
@@ -67,7 +68,7 @@
*
* @param assertionValue The assertionValue to set.
*/
- public void setAssertionValue( Object assertionValue )
+ public void setAssertionValue( Value<?> assertionValue )
{
this.assertionValue = assertionValue;
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/TwixTransformer.java Wed Apr 30 17:06:41 2008
@@ -443,58 +443,26 @@
switch ( ( ( AttributeValueAssertionFilter ) twixFilter ).getFilterType() )
{
case LdapConstants.EQUALITY_MATCH_FILTER:
- if ( ava.getAssertionValue() instanceof String )
- {
- branch = new EqualityNode( ava.getAttributeDesc(),
- (String)ava.getAssertionValue() );
- }
- else
- {
- branch = new EqualityNode( ava.getAttributeDesc(),
- (byte[])ava.getAssertionValue() );
- }
+ branch = new EqualityNode( ava.getAttributeDesc(),
+ ava.getAssertionValue() );
break;
case LdapConstants.GREATER_OR_EQUAL_FILTER:
- if ( ava.getAssertionValue() instanceof String )
- {
- branch = new GreaterEqNode( ava.getAttributeDesc(),
- (String)ava.getAssertionValue() );
- }
- else
- {
- branch = new GreaterEqNode( ava.getAttributeDesc(),
- (byte[])ava.getAssertionValue() );
- }
+ branch = new GreaterEqNode( ava.getAttributeDesc(),
+ ava.getAssertionValue() );
break;
case LdapConstants.LESS_OR_EQUAL_FILTER:
- if ( ava.getAssertionValue() instanceof String )
- {
- branch = new LessEqNode( ava.getAttributeDesc(),
- (String)ava.getAssertionValue() );
- }
- else
- {
- branch = new LessEqNode( ava.getAttributeDesc(),
- (byte[])ava.getAssertionValue() );
- }
+ branch = new LessEqNode( ava.getAttributeDesc(),
+ ava.getAssertionValue() );
break;
case LdapConstants.APPROX_MATCH_FILTER:
- if ( ava.getAssertionValue() instanceof String )
- {
- branch = new ApproximateNode( ava.getAttributeDesc(),
- (String)ava.getAssertionValue() );
- }
- else
- {
- branch = new ApproximateNode( ava.getAttributeDesc(),
- (byte[])ava.getAssertionValue() );
- }
+ branch = new ApproximateNode( ava.getAttributeDesc(),
+ ava.getAssertionValue() );
break;
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAssertionValueFilterAction.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAssertionValueFilterAction.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAssertionValueFilterAction.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/actions/InitAssertionValueFilterAction.java Wed Apr 30 17:06:41 2008
@@ -29,6 +29,9 @@
import org.apache.directory.shared.ldap.codec.LdapMessageContainer;
import org.apache.directory.shared.ldap.codec.search.AttributeValueAssertionFilter;
import org.apache.directory.shared.ldap.codec.search.SearchRequest;
+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.util.StringTools;
import org.slf4j.Logger;
@@ -65,11 +68,15 @@
TLV tlv = ldapMessageContainer.getCurrentTLV();
// The value can be null.
- Object assertionValue = StringTools.EMPTY_BYTES;
+ Value<?> assertionValue = null;
if ( tlv.getLength() != 0 )
{
- assertionValue = tlv.getValue().getData();
+ assertionValue = new ClientBinaryValue( tlv.getValue().getData() );
+ }
+ else
+ {
+ assertionValue = new ClientBinaryValue( StringTools.EMPTY_BYTES );
}
AttributeValueAssertionFilter terminalFilter = ( AttributeValueAssertionFilter ) searchRequest
@@ -78,11 +85,29 @@
if ( ldapMessageContainer.isBinary( assertion.getAttributeDesc() ) )
{
+ if ( tlv.getLength() != 0 )
+ {
+ assertionValue = new ClientBinaryValue( tlv.getValue().getData() );
+ }
+ else
+ {
+ assertionValue = new ClientBinaryValue( StringTools.EMPTY_BYTES );
+ }
+
assertion.setAssertionValue( assertionValue );
}
else
{
- assertion.setAssertionValue( StringTools.utf8ToString( ( byte[] ) assertionValue ) );
+ if ( tlv.getLength() != 0 )
+ {
+ assertionValue = new ClientStringValue( StringTools.utf8ToString( tlv.getValue().getData() ) );
+ }
+ else
+ {
+ assertionValue = new ClientStringValue( "" );
+ }
+
+ assertion.setAssertionValue(assertionValue );
}
// We now have to get back to the nearest filter which is
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java Wed Apr 30 17:06:41 2008
@@ -28,6 +28,8 @@
import org.apache.directory.shared.asn1.codec.EncoderException;
import org.apache.directory.shared.ldap.codec.AttributeValueAssertion;
import org.apache.directory.shared.ldap.codec.LdapConstants;
+import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -152,17 +154,17 @@
avaLength = 1 + TLV.getNbBytes( attributeDescLength ) + attributeDescLength;
- Object assertionValue = assertion.getAssertionValue();
+ org.apache.directory.shared.ldap.entry.Value<?> assertionValue = assertion.getAssertionValue();
int assertionValueLength = 0;
- if ( assertionValue instanceof String )
+ if ( assertionValue instanceof ClientStringValue )
{
- assertionValueLength = StringTools.getBytesUtf8( ( String ) assertionValue ).length;
+ assertionValueLength = StringTools.getBytesUtf8( ((ClientStringValue)assertionValue).get() ).length;
}
else
{
- assertionValueLength = ( ( byte[] ) assertionValue ).length;
+ assertionValueLength = ((ClientBinaryValue)assertionValue).get().length;
}
avaLength += 1 + TLV.getNbBytes( assertionValueLength ) + assertionValueLength;
@@ -228,13 +230,13 @@
Value.encode( buffer, assertion.getAttributeDesc() );
// The assertion desc
- if ( assertion.getAssertionValue() instanceof String )
+ if ( assertion.getAssertionValue().get() instanceof String )
{
- Value.encode( buffer, ( String ) assertion.getAssertionValue() );
+ Value.encode( buffer, ( String ) assertion.getAssertionValue().get() );
}
else
{
- Value.encode( buffer, ( byte[] ) assertion.getAssertionValue() );
+ Value.encode( buffer, ( byte[] ) assertion.getAssertionValue().get() );
}
return buffer;
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/Value.java Wed Apr 30 17:06:41 2008
@@ -171,4 +171,12 @@
* @exception NamingException If the value cannot be normalized
*/
void normalize( Normalizer normalizer ) throws NamingException;
+
+
+ /**
+ * Tells if the current value is Binary or String
+ *
+ * @return <code>true</code> if the value is Binary, <code>false</code> otherwise
+ */
+ boolean isBinary();
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientBinaryValue.java Wed Apr 30 17:06:41 2008
@@ -338,6 +338,17 @@
System.arraycopy( wrapped, 0, copy, 0, wrapped.length );
return copy;
}
+
+
+ /**
+ * Tells if the current value is Binary or String
+ *
+ * @return <code>true</code> if the value is Binary, <code>false</code> otherwise
+ */
+ public boolean isBinary()
+ {
+ return true;
+ }
/**
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/ClientStringValue.java Wed Apr 30 17:06:41 2008
@@ -295,6 +295,17 @@
/**
+ * Tells if the current value is Binary or String
+ *
+ * @return <code>true</code> if the value is Binary, <code>false</code> otherwise
+ */
+ public boolean isBinary()
+ {
+ return false;
+ }
+
+
+ /**
* @see Externalizable#readExternal(ObjectInput)
*/
public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
@@ -318,6 +329,6 @@
*/
public String toString()
{
- return "'" + wrapped + "'";
+ return wrapped == null ? "null": wrapped;
}
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/entry/client/DefaultClientEntry.java Wed Apr 30 17:06:41 2008
@@ -29,6 +29,8 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.SortedMap;
+import java.util.TreeMap;
import org.apache.directory.shared.ldap.entry.AbstractEntry;
import org.apache.directory.shared.ldap.entry.Entry;
@@ -1050,11 +1052,18 @@
result = result*17 + dn.hashCode();
- for ( EntryAttribute attribute:attributes.values() )
+ SortedMap<String, EntryAttribute> sortedMap = new TreeMap<String, EntryAttribute>();
+
+ for ( String id:attributes.keySet() )
{
- result = result*17 + attribute.hashCode();
+ sortedMap.put( id, attributes.get( id ) );
}
-
+
+ for ( String id:sortedMap.keySet() )
+ {
+ result = result*17 + sortedMap.get( id ).hashCode();
+ }
+
return result;
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/ApproximateNode.java Wed Apr 30 17:06:41 2008
@@ -19,6 +19,7 @@
*/
package org.apache.directory.shared.ldap.filter;
+import org.apache.directory.shared.ldap.entry.Value;
/**
* A simple assertion value node.
@@ -34,19 +35,7 @@
* @param attribute the attribute name
* @param value the value to test for
*/
- public ApproximateNode( String attribute, byte[] value )
- {
- super( attribute, value, AssertionType.APPROXIMATE );
- }
-
-
- /**
- * Creates a new ApproximateNode object.
- *
- * @param attribute the attribute name
- * @param value the value to test for
- */
- public ApproximateNode( String attribute, String value )
+ public ApproximateNode( String attribute, Value<?> value )
{
super( attribute, value, AssertionType.APPROXIMATE );
}
@@ -66,14 +55,14 @@
*/
public String toString()
{
- StringBuilder buf = new StringBuilder();
-
+ StringBuilder buf = new StringBuilder();
+
buf.append( '(' ).append( getAttribute() ).append( "~=" ).append( value );
buf.append( super.toString() );
buf.append( ')' );
- return buf.toString();
+ return buf.toString();
}
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/EqualityNode.java Wed Apr 30 17:06:41 2008
@@ -19,6 +19,8 @@
*/
package org.apache.directory.shared.ldap.filter;
+import org.apache.directory.shared.ldap.entry.Value;
+
/**
* A assertion value node for Equality.
@@ -34,19 +36,7 @@
* @param attribute the attribute name
* @param value the value to test for
*/
- public EqualityNode( String attribute, byte[] value )
- {
- super( attribute, value, AssertionType.EQUALITY );
- }
-
-
- /**
- * Creates a new Equality object.
- *
- * @param attribute the attribute name
- * @param value the value to test for
- */
- public EqualityNode( String attribute, String value )
+ public EqualityNode( String attribute, Value<?> value )
{
super( attribute, value, AssertionType.EQUALITY );
}
@@ -58,19 +48,7 @@
* @param attribute the attribute name
* @param value the value to test for
*/
- protected EqualityNode( String attribute, byte[] value, AssertionType assertionType )
- {
- super( attribute, value, assertionType );
- }
-
-
- /**
- * Creates a new Equality object.
- *
- * @param attribute the attribute name
- * @param value the value to test for
- */
- protected EqualityNode( String attribute, String value, AssertionType assertionType )
+ protected EqualityNode( String attribute, Value<?> value, AssertionType assertionType )
{
super( attribute, value, assertionType );
}
@@ -90,14 +68,14 @@
*/
public String toString()
{
- StringBuilder buf = new StringBuilder();
-
+ StringBuilder buf = new StringBuilder();
+
buf.append( '(' ).append( getAttribute() ).append( "=" ).append( value );
buf.append( super.toString() );
buf.append( ')' );
- return buf.toString();
+ return buf.toString();
}
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/FilterParser.java Wed Apr 30 17:06:41 2008
@@ -22,6 +22,7 @@
import java.text.ParseException;
+import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
import org.apache.directory.shared.ldap.util.AttributeUtils;
import org.apache.directory.shared.ldap.util.Position;
import org.apache.directory.shared.ldap.util.StringTools;
@@ -35,7 +36,8 @@
public FilterParser()
{
}
-
+
+
/**
* Parse an extensible
*
@@ -61,35 +63,35 @@
// Push back the ':'
pos.start--;
}
-
+
// Do we have a MatchingRule ?
if ( StringTools.charAt( filter, pos.start ) == ':' )
{
pos.start++;
int start = pos.start;
-
+
if ( StringTools.charAt( filter, pos.start ) == '=' )
{
pos.start++;
-
+
// Get the assertionValue
node.setValue( parseAssertionValue( filter, pos ) );
-
+
return node;
}
else
{
AttributeUtils.parseAttribute( filter, pos, false );
-
+
node.setMatchingRuleId( filter.substring( start, pos.start ) );
-
+
if ( StringTools.areEquals( filter, pos.start, ":=" ) )
{
pos.start += 2;
-
+
// Get the assertionValue
node.setValue( parseAssertionValue( filter, pos ) );
-
+
return node;
}
else
@@ -106,7 +108,7 @@
else
{
boolean oidRequested = false;
-
+
// First check if we have a ":dn"
if ( StringTools.areEquals( filter, pos.start, ":dn" ) )
{
@@ -118,40 +120,40 @@
{
oidRequested = true;
}
-
+
// Do we have a MatchingRule ?
if ( StringTools.charAt( filter, pos.start ) == ':' )
{
pos.start++;
int start = pos.start;
-
+
if ( StringTools.charAt( filter, pos.start ) == '=' )
{
if ( oidRequested )
{
throw new ParseException( "MatchingRule expected", pos.start );
}
-
+
pos.start++;
-
+
// Get the assertionValue
node.setValue( parseAssertionValue( filter, pos ) );
-
+
return node;
}
else
{
AttributeUtils.parseAttribute( filter, pos, false );
-
+
node.setMatchingRuleId( filter.substring( start, pos.start ) );
-
+
if ( StringTools.areEquals( filter, pos.start, ":=" ) )
{
pos.start += 2;
-
+
// Get the assertionValue
node.setValue( parseAssertionValue( filter, pos ) );
-
+
return node;
}
else
@@ -166,8 +168,8 @@
}
}
}
-
-
+
+
/**
* An assertion value :
* assertionvalue = valueencoding
@@ -204,9 +206,9 @@
private static String parseAssertionValue( String filter, Position pos ) throws ParseException
{
int start = pos.start;
-
+
char c = StringTools.charAt( filter, pos.start );
-
+
do
{
if ( StringTools.isUnicodeSubset( c ) )
@@ -217,7 +219,7 @@
{
// Maybe an escaped
pos.start++;
-
+
// First hex
if ( StringTools.isHex( filter, pos.start ) )
{
@@ -243,35 +245,38 @@
// not a valid char, so let's get out
return filter.substring( start, pos.start );
}
- } while ( ( c = StringTools.charAt( filter, pos.start ) ) != '\0' );
-
+ }
+ while ( ( c = StringTools.charAt( filter, pos.start ) ) != '\0' );
+
return filter.substring( start, pos.start );
}
+
/**
* Parse a substring
*/
- private static ExprNode parseSubstring( String attr, String initial, String filter, Position pos ) throws ParseException
+ private static ExprNode parseSubstring( String attr, String initial, String filter, Position pos )
+ throws ParseException
{
if ( StringTools.isCharASCII( filter, pos.start, '*' ) )
{
// We have found a '*' : this is a substring
SubstringNode node = new SubstringNode( attr );
-
+
if ( !StringTools.isEmpty( initial ) )
{
// We have a substring starting with a value : val*...
// Set the initial value
node.setInitial( initial );
}
-
+
pos.start++;
-
+
//
while ( true )
{
String assertionValue = parseAssertionValue( filter, pos );
-
+
// Is there anything else but a ')' after the value ?
if ( StringTools.isCharASCII( filter, pos.start, ')' ) )
{
@@ -293,10 +298,10 @@
{
node.addAny( assertionValue );
}
-
+
pos.start++;
}
- }
+ }
}
else
{
@@ -304,7 +309,8 @@
throw new ParseException( "Bad substring", pos.start );
}
}
-
+
+
/**
* Here is the grammar to parse :
*
@@ -329,7 +335,8 @@
* @param pos
* @return
*/
- private static ExprNode parsePresenceEqOrSubstring( String attr, String filter, Position pos ) throws ParseException
+ private static ExprNode parsePresenceEqOrSubstring( String attr, String filter, Position pos )
+ throws ParseException
{
if ( StringTools.isCharASCII( filter, pos.start, '*' ) )
{
@@ -353,25 +360,25 @@
else if ( StringTools.isCharASCII( filter, pos.start, ')' ) )
{
// An empty equality Node
- return new EqualityNode( attr, "" );
+ return new EqualityNode( attr, new ClientStringValue( "" ) );
}
else
{
// A substring or an equality node
String value = parseAssertionValue( filter, pos );
-
+
// Is there anything else but a ')' after the value ?
if ( StringTools.isCharASCII( filter, pos.start, ')' ) )
{
// This is an equality node
- return new EqualityNode( attr, value );
+ return new EqualityNode( attr, new ClientStringValue( value ) );
}
-
+
return parseSubstring( attr, value, filter, pos );
}
}
-
-
+
+
/**
* Parse the following grammar :
* item = simple / present / substring / extensible
@@ -389,15 +396,15 @@
{
LeafNode node = null;
String attr = null;
-
+
// Relax the grammar a bit : we can have spaces
// StringTools.trimLeft( filter, pos );
-
+
if ( c == '\0' )
{
throw new ParseException( "Bad char", pos.start );
}
-
+
if ( c == ':' )
{
// If we have a colon, then the item is an extensible one
@@ -407,24 +414,24 @@
{
// We must have an attribute
attr = AttributeUtils.parseAttribute( filter, pos, true );
-
+
// Relax the grammar a bit : we can have spaces
// StringTools.trimLeft( filter, pos );
// Now, we may have a present, substring, simple or an extensible
c = StringTools.charAt( filter, pos.start );
-
+
switch ( c )
{
- case '=' :
+ case '=':
// It can be a presence, an equal or a substring
pos.start++;
return parsePresenceEqOrSubstring( attr, filter, pos );
-
- case '~' :
+
+ case '~':
// Approximate node
pos.start++;
-
+
// Check that we have a '='
if ( !StringTools.isCharASCII( filter, pos.start, '=' ) )
{
@@ -432,15 +439,15 @@
}
pos.start++;
-
+
// Parse the value and create the node
- node = new ApproximateNode( attr, parseAssertionValue( filter, pos ) );
+ node = new ApproximateNode( attr, new ClientStringValue( parseAssertionValue( filter, pos ) ) );
return node;
-
- case '>' :
+
+ case '>':
// Greater or equal node
pos.start++;
-
+
// Check that we have a '='
if ( !StringTools.isCharASCII( filter, pos.start, '=' ) )
{
@@ -448,15 +455,15 @@
}
pos.start++;
-
+
// Parse the value and create the node
- node = new GreaterEqNode( attr, parseAssertionValue( filter, pos ) );
+ node = new GreaterEqNode( attr, new ClientStringValue( parseAssertionValue( filter, pos ) ) );
return node;
-
- case '<' :
+
+ case '<':
// Less or equal node
pos.start++;
-
+
// Check that we have a '='
if ( !StringTools.isCharASCII( filter, pos.start, '=' ) )
{
@@ -464,23 +471,24 @@
}
pos.start++;
-
+
// Parse the value and create the node
- node = new LessEqNode( attr, parseAssertionValue( filter, pos ) );
+ node = new LessEqNode( attr, new ClientStringValue( parseAssertionValue( filter, pos ) ) );
return node;
-
- case ':' :
+
+ case ':':
// An extensible node
pos.start++;
return parseExtensible( attr, filter, pos );
-
- default :
+
+ default:
// This is an error
throw new ParseException( "An item is expected", pos.start );
}
}
}
+
/**
* Parse AND, OR and NOT nodes :
*
@@ -493,20 +501,20 @@
*/
private static ExprNode parseBranchNode( ExprNode node, String filter, Position pos ) throws ParseException
{
- BranchNode bNode = (BranchNode)node;
-
+ BranchNode bNode = ( BranchNode ) node;
+
// Relax the grammar a bit : we can have spaces
// StringTools.trimLeft( filter, pos );
-
+
// We must have at least one filter
ExprNode child = parseFilterInternal( filter, pos );
-
+
// Add the child to the node children
bNode.addNode( child );
// Relax the grammar a bit : we can have spaces
// StringTools.trimLeft( filter, pos );
-
+
// Now, iterate though all the remaining filters, if any
while ( ( child = parseFilterInternal( filter, pos ) ) != null )
{
@@ -516,13 +524,14 @@
// Relax the grammar a bit : we can have spaces
// StringTools.trimLeft( filter, pos );
}
-
+
// Relax the grammar a bit : we can have spaces
// StringTools.trimLeft( filter, pos );
return node;
}
+
/**
* filtercomp = and / or / not / item
* and = '&' filterlist
@@ -537,53 +546,54 @@
* / ( [dnattrs]
* matchingrule COLON EQUALS assertionvalue )
*/
- private static ExprNode parseFilterComp( String filter, Position pos ) throws ParseException
+ private static ExprNode parseFilterComp( String filter, Position pos ) throws ParseException
{
ExprNode node = null;
// Relax the grammar a bit : we can have spaces
// StringTools.trimLeft( filter, pos );
-
+
if ( pos.start == pos.length )
{
throw new ParseException( "Empty filterComp", pos.start );
}
-
+
char c = StringTools.charAt( filter, pos.start );
-
+
switch ( c )
{
- case '&' :
+ case '&':
// This is a AND node
pos.start++;
node = new AndNode();
parseBranchNode( node, filter, pos );
break;
-
- case '|' :
+
+ case '|':
// This is an OR node
pos.start++;
node = new OrNode();
parseBranchNode( node, filter, pos );
break;
-
- case '!' :
+
+ case '!':
// This is a NOT node
pos.start++;
node = new NotNode();
parseBranchNode( node, filter, pos );
break;
-
- default :
+
+ default:
// This is an item
node = parseItem( filter, pos, c );
break;
-
+
}
-
+
return node;
}
-
+
+
/**
* Pasre the grammar rule :
* filter ::= '(' filterComp ')'
@@ -592,7 +602,7 @@
{
// relax the grammar by allowing spaces
// StringTools.trimLeft( filter, pos );
-
+
// Check for the left '('
if ( StringTools.isCharASCII( filter, pos.start, '(' ) == false )
{
@@ -606,34 +616,35 @@
return null;
}
}
-
+
pos.start++;
-
+
// relax the grammar by allowing spaces
// StringTools.trimLeft( filter, pos );
-
+
// parse the filter component
ExprNode node = parseFilterComp( filter, pos );
-
+
if ( node == null )
{
throw new ParseException( "Bad filter", pos.start );
}
-
+
// relax the grammar by allowing spaces
// StringTools.trimLeft( filter, pos );
-
+
// Check that we have a right ')'
if ( StringTools.isCharASCII( filter, pos.start, ')' ) == false )
{
throw new ParseException( "The filter has no right parenthese", pos.start );
}
-
+
pos.start++;
-
+
return node;
}
-
+
+
/**
* @see FilterParser#parse(String)
*/
@@ -644,12 +655,12 @@
{
throw new ParseException( "Empty filter", 0 );
}
-
+
Position pos = new Position();
pos.start = 0;
pos.end = 0;
pos.length = filter.length();
-
+
return parseFilterInternal( filter, pos );
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/GreaterEqNode.java Wed Apr 30 17:06:41 2008
@@ -20,6 +20,9 @@
package org.apache.directory.shared.ldap.filter;
+import org.apache.directory.shared.ldap.entry.Value;
+
+
/**
* A assertion value node for GreaterOrEqual.
*
@@ -34,19 +37,7 @@
* @param attribute the attribute name
* @param value the value to test for
*/
- public GreaterEqNode( String attribute, byte[] value )
- {
- super( attribute, value, AssertionType.GREATEREQ );
- }
-
-
- /**
- * Creates a new GreaterOrEqual object.
- *
- * @param attribute the attribute name
- * @param value the value to test for
- */
- public GreaterEqNode( String attribute, String value )
+ public GreaterEqNode( String attribute, Value<?> value )
{
super( attribute, value, AssertionType.GREATEREQ );
}
@@ -60,20 +51,20 @@
return super.hashCode();
}
-
+
/**
* @see Object#toString()
*/
public String toString()
{
- StringBuilder buf = new StringBuilder();
-
+ StringBuilder buf = new StringBuilder();
+
buf.append( '(' ).append( getAttribute() ).append( ">=" ).append( value );
buf.append( super.toString() );
-
+
buf.append( ')' );
-
- return buf.toString();
+
+ return buf.toString();
}
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/LessEqNode.java Wed Apr 30 17:06:41 2008
@@ -20,6 +20,9 @@
package org.apache.directory.shared.ldap.filter;
+import org.apache.directory.shared.ldap.entry.Value;
+
+
/**
* A assertion value node for LessOrEqual.
*
@@ -34,25 +37,13 @@
* @param attribute the attribute name
* @param value the value to test for
*/
- public LessEqNode( String attribute, byte[] value )
+ public LessEqNode( String attribute, Value<?> value )
{
super( attribute, value, AssertionType.LESSEQ );
}
/**
- * Creates a new LessEqNode object.
- *
- * @param attribute the attribute name
- * @param value the value to test for
- */
- public LessEqNode( String attribute, String value )
- {
- super( attribute, value, AssertionType.LESSEQ );
- }
-
-
- /**
* @see Object#hashCode()
*/
public int hashCode()
@@ -60,20 +51,20 @@
return super.hashCode();
}
-
+
/**
* @see Object#toString()
*/
public String toString()
{
- StringBuilder buf = new StringBuilder();
-
+ StringBuilder buf = new StringBuilder();
+
buf.append( '(' ).append( getAttribute() ).append( "<=" ).append( value );
buf.append( super.toString() );
-
+
buf.append( ')' );
-
- return buf.toString();
+
+ return buf.toString();
}
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/filter/SimpleNode.java Wed Apr 30 17:06:41 2008
@@ -19,7 +19,9 @@
*/
package org.apache.directory.shared.ldap.filter;
+
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.Value;
/**
@@ -30,25 +32,13 @@
*/
public abstract class SimpleNode extends LeafNode
{
- /** the value */
- protected Object value;
+ /** the value */
+ protected Value<?> value;
/** Constants for comparisons */
public final static boolean EVAL_GREATER = true;
public final static boolean EVAL_LESSER = false;
- /**
- * Creates a new SimpleNode object.
- *
- * @param attribute the attribute name
- * @param value the value to test for
- */
- protected SimpleNode( String attribute, byte[] value, AssertionType assertionType )
- {
- super( attribute, assertionType );
- this.value = value;
- }
-
/**
* Creates a new SimpleNode object.
@@ -56,7 +46,7 @@
* @param attribute the attribute name
* @param value the value to test for
*/
- protected SimpleNode( String attribute, String value, AssertionType assertionType )
+ protected SimpleNode( String attribute, Value<?> value, AssertionType assertionType )
{
super( attribute, assertionType );
this.value = value;
@@ -68,7 +58,7 @@
*
* @return the value
*/
- public final Object getValue()
+ public final Value<?> getValue()
{
return value;
}
@@ -79,7 +69,7 @@
*
* @param value the value for this node
*/
- public void setValue( Object value )
+ public void setValue( Value<?> value )
{
this.value = value;
}
@@ -103,7 +93,7 @@
return buf;
}
-
+
/**
* @see ExprNode#printRefinementToBuffer(StringBuilder)
*/
@@ -125,15 +115,15 @@
*/
public int hashCode()
{
- int h = 37;
-
- h = h*17 + super.hashCode();
- h = h*17 + ( value == null ? 0 : value.hashCode() );
-
- return h;
+ int h = 37;
+
+ h = h * 17 + super.hashCode();
+ h = h * 17 + ( value == null ? 0 : value.hashCode() );
+
+ return h;
}
-
+
/*
* (non-Javadoc)
*
@@ -150,26 +140,26 @@
{
return false;
}
-
+
if ( other.getClass() != this.getClass() )
{
- return false;
+ return false;
}
-
+
if ( !super.equals( other ) )
{
- return false;
+ return false;
}
- SimpleNode otherNode = (SimpleNode)other;
+ SimpleNode otherNode = ( SimpleNode ) other;
if ( value == null )
{
- return otherNode.value == null;
+ return otherNode.value == null;
}
else
{
- return value.equals( otherNode.value );
- }
+ return value.equals( otherNode.value );
+ }
}
}
Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDNSerializer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDNSerializer.java?rev=652410&r1=652409&r2=652410&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDNSerializer.java (original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/LdapDNSerializer.java Wed Apr 30 17:06:41 2008
@@ -77,7 +77,7 @@
}
else
{
- String message = "The DN should have been normalized before being serialized";
+ String message = "The DN should have been normalized before being serialized " + dn;
LOG.error( message );
throw new IOException( message );
}