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 2009/05/30 19:10:06 UTC
svn commit: r780299 - in /directory:
apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/
apacheds/trunk/core-shared/src/test/java/org/apache/directory/server/core/
apacheds/trunk/core/src/main/java/org/apache/directory/server/cor...
Author: elecharny
Date: Sat May 30 17:10:05 2009
New Revision: 780299
URL: http://svn.apache.org/viewvc?rev=780299&view=rev
Log:
o Renamed the existenceIdx index to presenceIdx
o First addition of a EntryCSN, EntryUUID and ObjectClass indexes
o Added the EntryCSN and EntryUUID AT in entries
o Fixed a bug in CSN
o Removed the server-core CSN classes (they are already present in shared)
o Adding some Javadoc
o Minor cleanup
Removed:
directory/apacheds/trunk/core-shared/src/main/java/org/apache/directory/server/core/
directory/apacheds/trunk/core-shared/src/test/java/org/apache/directory/server/core/CSNFactoryTest.java
directory/apacheds/trunk/core-shared/src/test/java/org/apache/directory/server/core/CSNTest.java
Modified:
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSN.java
directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNTest.java
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=780299&r1=780298&r2=780299&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Sat May 30 17:10:05 2009
@@ -82,6 +82,8 @@
import org.apache.directory.shared.ldap.NotImplementedException;
import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.csn.CSN;
+import org.apache.directory.shared.ldap.csn.CSNFactory;
import org.apache.directory.shared.ldap.cursor.Cursor;
import org.apache.directory.shared.ldap.entry.Entry;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=780299&r1=780298&r2=780299&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DirectoryService.java Sat May 30 17:10:05 2009
@@ -32,6 +32,7 @@
import org.apache.directory.server.core.partition.PartitionNexus;
import org.apache.directory.server.core.schema.SchemaService;
import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.csn.CSN;
import org.apache.directory.shared.ldap.ldif.LdifEntry;
import org.apache.directory.shared.ldap.name.LdapDN;
Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java?rev=780299&r1=780298&r2=780299&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java Sat May 30 17:10:05 2009
@@ -20,7 +20,6 @@
package org.apache.directory.server.core.authz.support;
-import org.apache.directory.server.core.CSN;
import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.core.DefaultCoreSession;
import org.apache.directory.server.core.DefaultDirectoryService;
@@ -68,6 +67,7 @@
import org.apache.directory.shared.ldap.aci.ProtectedItem;
import org.apache.directory.shared.ldap.aci.UserClass;
import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
+import org.apache.directory.shared.ldap.csn.CSN;
import org.apache.directory.shared.ldap.cursor.ClosureMonitor;
import org.apache.directory.shared.ldap.cursor.Cursor;
import org.apache.directory.shared.ldap.cursor.CursorIterator;
Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java?rev=780299&r1=780298&r2=780299&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java Sat May 30 17:10:05 2009
@@ -22,7 +22,6 @@
import junit.framework.TestCase;
-import org.apache.directory.server.core.CSN;
import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.core.DefaultCoreSession;
import org.apache.directory.server.core.DirectoryService;
@@ -42,6 +41,7 @@
import org.apache.directory.server.core.schema.SchemaService;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
+import org.apache.directory.shared.ldap.csn.CSN;
import org.apache.directory.shared.ldap.ldif.LdifEntry;
import org.apache.directory.shared.ldap.name.LdapDN;
Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=780299&r1=780298&r2=780299&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Sat May 30 17:10:05 2009
@@ -112,8 +112,8 @@
/** the user provided distinguished name index */
private JdbmIndex<String,E> updnIdx;
- /** the attribute existence index */
- private JdbmIndex<String,E> existenceIdx;
+ /** the attribute presence index */
+ private JdbmIndex<String,E> presenceIdx;
/** a system index on aliasedObjectName attribute */
private JdbmIndex<String,E> aliasIdx;
@@ -130,8 +130,20 @@
/** the subtree scope alias index */
private JdbmIndex<Long,E> subAliasIdx;
- /** Two static declaration to avoid lookup all over the code */
+
+ /** a system index on objectClass attribute*/
+ private JdbmIndex<String,E> objectClassIdx;
+
+ /** a system index on entryCSN attribute */
+ private JdbmIndex<String,E> entryCsnIdx;
+
+ /** a system index on entryUUID attribute */
+ private JdbmIndex<byte[],E> entryUuidIdx;
+
+ /** Static declarations to avoid lookup all over the code */
private static AttributeType OBJECT_CLASS_AT;
+ private static AttributeType ENTRY_CSN_AT;
+ private static AttributeType ENTRY_UUID_AT;
private static AttributeType ALIASED_OBJECT_NAME_AT;
/** A pointer on the AT registry */
@@ -140,12 +152,13 @@
/** A pointer on the OID registry */
private OidRegistry oidRegistry;
+ private String suffixDn;
+ private int cacheSize = DEFAULT_CACHE_SIZE;
+ private String name;
// ------------------------------------------------------------------------
// C O N S T R U C T O R S
// ------------------------------------------------------------------------
-
-
/**
* Creates a store based on JDBM B+Trees.
*/
@@ -157,13 +170,6 @@
// -----------------------------------------------------------------------
// C O N F I G U R A T I O N M E T H O D S
// -----------------------------------------------------------------------
-
-
- private String suffixDn;
- private int cacheSize = DEFAULT_CACHE_SIZE;
- private String name;
-
-
private void protect( String property )
{
if ( initialized )
@@ -254,8 +260,11 @@
this.oidRegistry = registries.getOidRegistry();
this.attributeTypeRegistry = registries.getAttributeTypeRegistry();
+ // Initialize Attribute types used all over this method
OBJECT_CLASS_AT = attributeTypeRegistry.lookup( SchemaConstants.OBJECT_CLASS_AT );
ALIASED_OBJECT_NAME_AT = attributeTypeRegistry.lookup( SchemaConstants.ALIASED_OBJECT_NAME_AT );
+ ENTRY_CSN_AT = attributeTypeRegistry.lookup( SchemaConstants.ENTRY_CSN_AT );
+ ENTRY_UUID_AT = attributeTypeRegistry.lookup( SchemaConstants.ENTRY_UUID_AT );
this.upSuffix = new LdapDN( suffixDn );
this.normSuffix = LdapDN.normalize( upSuffix, attributeTypeRegistry.getNormalizerMapping() );
@@ -326,12 +335,12 @@
updnIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ), workingDirectory );
}
- if ( existenceIdx == null )
+ if ( presenceIdx == null )
{
- existenceIdx = new JdbmIndex<String,E>();
- existenceIdx.setAttributeId( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
- systemIndices.put( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID, existenceIdx );
- existenceIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ), workingDirectory );
+ presenceIdx = new JdbmIndex<String,E>();
+ presenceIdx.setAttributeId( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
+ systemIndices.put( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID, presenceIdx );
+ presenceIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ), workingDirectory );
}
if ( oneLevelIdx == null )
@@ -509,7 +518,7 @@
array.add( oneAliasIdx );
array.add( subAliasIdx );
array.add( oneLevelIdx );
- array.add( existenceIdx );
+ array.add( presenceIdx );
array.add( subLevelIdx );
// Sync all user defined userIndices
@@ -566,26 +575,41 @@
}
+ //------------------------------------------------------------------------
+ // System index
+ //------------------------------------------------------------------------
+ /**
+ * {@inheritDoc}
+ */
public Index<String,E> getPresenceIndex()
{
- return existenceIdx;
+ return presenceIdx;
}
+ /**
+ * {@inheritDoc}
+ */
public void setPresenceIndex( Index<String,E> index ) throws Exception
{
- protect( "existanceIndex" );
- existenceIdx = convertIndex( index );
- systemIndices.put( index.getAttributeId(), existenceIdx );
+ protect( "presenceIndex" );
+ presenceIdx = convertIndex( index );
+ systemIndices.put( index.getAttributeId(), presenceIdx );
}
+ /**
+ * {@inheritDoc}
+ */
public Index<Long,E> getOneLevelIndex()
{
return oneLevelIdx;
}
+ /**
+ * {@inheritDoc}
+ */
public void setOneLevelIndex( Index<Long,E> index ) throws Exception
{
protect( "hierarchyIndex" );
@@ -594,12 +618,18 @@
}
+ /**
+ * {@inheritDoc}
+ */
public Index<String,E> getAliasIndex()
{
return aliasIdx;
}
+ /**
+ * {@inheritDoc}
+ */
public void setAliasIndex( Index<String,E> index ) throws NamingException
{
protect( "aliasIndex" );
@@ -608,12 +638,18 @@
}
+ /**
+ * {@inheritDoc}
+ */
public Index<Long,E> getOneAliasIndex()
{
return oneAliasIdx;
}
+ /**
+ * {@inheritDoc}
+ */
public void setOneAliasIndex( Index<Long,E> index ) throws NamingException
{
protect( "oneAliasIndex" );
@@ -622,12 +658,18 @@
}
+ /**
+ * {@inheritDoc}
+ */
public Index<Long,E> getSubAliasIndex()
{
return subAliasIdx;
}
+ /**
+ * {@inheritDoc}
+ */
public void setSubAliasIndex( Index<Long,E> index ) throws NamingException
{
protect( "subAliasIndex" );
@@ -636,12 +678,18 @@
}
+ /**
+ * {@inheritDoc}
+ */
public Index<String,E> getUpdnIndex()
{
return updnIdx;
}
+ /**
+ * {@inheritDoc}
+ */
public void setUpdnIndex( Index<String,E> index ) throws NamingException
{
protect( "updnIndex" );
@@ -650,12 +698,18 @@
}
+ /**
+ * {@inheritDoc}
+ */
public Index<String,E> getNdnIndex()
{
return ndnIdx;
}
+ /**
+ * {@inheritDoc}
+ */
public void setNdnIndex( Index<String,E> index ) throws NamingException
{
protect( "ndnIndex" );
@@ -664,12 +718,18 @@
}
+ /**
+ * {@inheritDoc}
+ */
public Index<Long,E> getSubLevelIndex()
{
return subLevelIdx;
}
+ /**
+ * {@inheritDoc}
+ */
public void setSubLevelIndex( Index<Long,E> index ) throws NamingException
{
protect( "subLevelIndex" );
@@ -678,6 +738,66 @@
}
+ /**
+ * {@inheritDoc}
+ */
+ public Index<String,E> getObjectClassIndex()
+ {
+ return objectClassIdx;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setObjectClassIndex( Index<String,E> index ) throws NamingException
+ {
+ protect( "objectClassIndex" );
+ objectClassIdx = convertIndex( index );
+ systemIndices.put( index.getAttributeId(), objectClassIdx );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Index<byte[],E> getEntryUuidIndex()
+ {
+ return entryUuidIdx;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setEntryUuidIndex( Index<byte[],E> index ) throws NamingException
+ {
+ protect( "entryUuidIndex" );
+ entryUuidIdx = convertIndex( index );
+ systemIndices.put( index.getAttributeId(), entryUuidIdx );
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public Index<String,E> getEntryCsnIndex()
+ {
+ return entryCsnIdx;
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setEntryCsnIndex( Index<String,E> index ) throws NamingException
+ {
+ protect( "entryCsnIndex" );
+ entryCsnIdx = convertIndex( index );
+ systemIndices.put( index.getAttributeId(), entryCsnIdx );
+ }
+
+
public Iterator<String> userIndices()
{
return userIndices.keySet().iterator();
@@ -912,7 +1032,7 @@
{
String msg = "[36] aliasDereferencingProblem - "
+ " the alias points to an entry outside of the " + upSuffix.getUpName()
- + " namingContext to an object whose existance cannot be determined.";
+ + " namingContext to an object whose existence cannot be determined.";
ResultCodeEnum rc = ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM;
LdapNamingException e = new LdapNamingException( msg, rc );
e.setResolvedName( aliasDn );
@@ -1005,8 +1125,6 @@
}
- // TODO Change signature to not require the DN parameter since it is now
- // in the ServerEntry !!!
/**
* {@inheritDoc}
*/
@@ -1018,27 +1136,24 @@
throw new Exception( "Cannot store a ClonedServerEntry" );
}
- Long id;
Long parentId;
-
- id = master.getNextId();
+ Long id = master.getNextId();
//
// Suffix entry cannot have a parent since it is the root so it is
// capped off using the zero value which no entry can have since
// entry sequences start at 1.
//
-
- LdapDN normName = entry.getDn();
+ LdapDN entryDn = entry.getDn();
LdapDN parentDn = null;
- if ( normName.getNormName().equals( normSuffix.getNormName() ) )
+ if ( entryDn.getNormName().equals( normSuffix.getNormName() ) )
{
parentId = 0L;
}
else
{
- parentDn = ( LdapDN ) normName.clone();
+ parentDn = ( LdapDN ) entryDn.clone();
parentDn.remove( parentDn.size() - 1 );
parentId = getEntryId( parentDn.toString() );
}
@@ -1053,10 +1168,10 @@
if ( objectClass == null )
{
- String msg = "Entry " + normName.getUpName() + " contains no objectClass attribute: " + entry;
+ String msg = "Entry " + entryDn.getUpName() + " contains no objectClass attribute: " + entry;
ResultCodeEnum rc = ResultCodeEnum.OBJECT_CLASS_VIOLATION;
NamingException e = new LdapSchemaViolationException( msg, rc );
- e.setResolvedName( normName );
+ e.setResolvedName( entryDn );
throw e;
}
@@ -1066,24 +1181,26 @@
if ( objectClass.contains( SchemaConstants.ALIAS_OC ) )
{
EntryAttribute aliasAttr = entry.get( ALIASED_OBJECT_NAME_AT );
- addAliasIndices( id, normName, aliasAttr.getString() );
+ addAliasIndices( id, entryDn, aliasAttr.getString() );
}
- if ( !Character.isDigit( normName.toNormName().charAt( 0 ) ) )
+ if ( !Character.isDigit( entryDn.toNormName().charAt( 0 ) ) )
{
- throw new IllegalStateException( "Not a normalized name: " + normName.toNormName() );
+ throw new IllegalStateException( "Not a normalized name: " + entryDn.toNormName() );
}
- ndnIdx.add( normName.toNormName(), id );
- updnIdx.add( normName.getUpName(), id );
+ ndnIdx.add( entryDn.toNormName(), id );
+ updnIdx.add( entryDn.getUpName(), id );
oneLevelIdx.add( parentId, id );
Long tempId = parentId;
- while( tempId != null && tempId != 0 && tempId != 1 )
+
+ while( ( tempId != null ) && ( tempId != 0 ) && ( tempId != 1 ) )
{
subLevelIdx.add( tempId, id );
tempId = getParentId( tempId );
}
+
subLevelIdx.add( id, id );
// Now work on the user defined userIndices
@@ -1104,7 +1221,7 @@
}
// Adds only those attributes that are indexed
- existenceIdx.add( attributeOid, id );
+ presenceIdx.add( attributeOid, id );
}
}
@@ -1123,6 +1240,9 @@
}
+ /**
+ * {@inheritDoc}
+ */
@SuppressWarnings("unchecked")
public void delete( Long id ) throws Exception
{
@@ -1166,7 +1286,7 @@
( ( JdbmIndex ) index ).drop( value.get(), id );
}
- existenceIdx.drop( attributeOid, id );
+ presenceIdx.drop( attributeOid, id );
}
}
@@ -1254,9 +1374,9 @@
}
// If the attr didn't exist for this id add it to existence index
- if ( !existenceIdx.forward( modsOid, id ) )
+ if ( !presenceIdx.forward( modsOid, id ) )
{
- existenceIdx.add( modsOid, id );
+ presenceIdx.add( modsOid, id );
}
}
@@ -1310,11 +1430,11 @@
/*
* If no attribute values exist for this entryId in the index then
- * we remove the existance index entry for the removed attribute.
+ * we remove the presence index entry for the removed attribute.
*/
if ( null == index.reverseLookup( id ) )
{
- existenceIdx.drop( modsOid, id );
+ presenceIdx.drop( modsOid, id );
}
}
@@ -1353,7 +1473,7 @@
}
// Aliases->single valued comp/partial attr removal is not relevant here
- if ( modsOid.equals( oidRegistry.getOid( SchemaConstants.ALIASED_OBJECT_NAME_AT ) ) )
+ if ( modsOid.equals( SchemaConstants.ALIASED_OBJECT_NAME_AT_OID ) )
{
dropAliasIndices( id );
}
@@ -1399,11 +1519,11 @@
/*
* If no attribute values exist for this entryId in the index then
- * we remove the existance index entry for the removed attribute.
+ * we remove the presence index entry for the removed attribute.
*/
if ( null == index.reverseLookup( id ) )
{
- existenceIdx.drop( modsOid, id );
+ presenceIdx.drop( modsOid, id );
}
}
@@ -1541,7 +1661,7 @@
* ====================================================================
* Add the new Rdn attribute to the entry. If an index exists on the
* new Rdn attribute we add the index for this attribute value pair.
- * Also we make sure that the existance index shows the existance of the
+ * Also we make sure that the presence index shows the existence of the
* new Rdn attribute within this entry.
*/
@@ -1574,9 +1694,9 @@
( ( JdbmIndex ) index ).add( newNormValue, id );
// Make sure the altered entry shows the existence of the new attrib
- if ( !existenceIdx.forward( newNormType, id ) )
+ if ( !presenceIdx.forward( newNormType, id ) )
{
- existenceIdx.add( newNormType, id );
+ presenceIdx.add( newNormType, id );
}
}
}
@@ -1592,7 +1712,7 @@
* removed all the attribute values of the old Rdn using a reverse
* lookup. If so that means we blew away the last value of the old
* Rdn attribute. In this case we need to remove the attrName/id
- * tuple from the existance index.
+ * tuple from the presence index.
*
* We only remove an ATAV of the old Rdn if it is not included in the
* new Rdn.
@@ -1629,11 +1749,11 @@
/*
* If there is no value for id in this index due to our
- * drop above we remove the oldRdnAttr from the existance idx
+ * drop above we remove the oldRdnAttr from the presence idx
*/
if ( null == index.reverseLookup( id ) )
{
- existenceIdx.drop( oldNormType, id );
+ presenceIdx.drop( oldNormType, id );
}
}
}
@@ -1694,10 +1814,12 @@
// update normalized DN index
ndnIdx.drop( id );
+
if ( !updn.isNormalized() )
{
updn.normalize( attributeTypeRegistry.getNormalizerMapping() );
}
+
ndnIdx.add( updn.toNormName(), id );
// update user provided DN index
Modified: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=780299&r1=780298&r2=780299&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java (original)
+++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java Sat May 30 17:10:05 2009
@@ -88,15 +88,28 @@
*/
+ /**
+ * Sets the working directory for the store
+ */
void setWorkingDirectory( File workingDirectory );
+ /**
+ * @return The current working directory for the store
+ */
File getWorkingDirectory();
+ /**
+ * Stores the list of user index
+ * @param userIndices The list of user index
+ */
void setUserIndices( Set<Index<?,E>> userIndices );
+ /**
+ * @return The list of user index
+ */
Set<Index<?,E>> getUserIndices();
@@ -106,21 +119,44 @@
String getSuffixDn();
+ /**
+ * Sets the flag telling the server to flush on disk when some
+ * modification has been done.
+ * @param isSyncOnWrite A boolean set to true if we have to flush on disk
+ * when a modification occurs
+ */
void setSyncOnWrite( boolean isSyncOnWrite );
+ /**
+ * @return <code>true</code> if we write to disk for every modification
+ */
boolean isSyncOnWrite();
+ /**
+ * Sets the cache size for this store
+ * @param cacheSize The cache size
+ */
void setCacheSize( int cacheSize );
+ /**
+ * @return The cache size
+ */
int getCacheSize();
+ /**
+ * Sets the store's name
+ * @param name The store's name
+ */
void setName( String name );
+ /**
+ * @return The store's name
+ */
String getName();
@@ -160,72 +196,218 @@
void sync() throws Exception;
+ /**
+ * Adds a user index to the list of index for this store
+ * @param index The index to add
+ * @throws Exception If the addition failed
+ */
void addIndex( Index<?,E> index ) throws Exception;
+ //------------------------------------------------------------------------
+ // System index
+ //------------------------------------------------------------------------
+ /**
+ * @return The Presence system index
+ */
Index<String,E> getPresenceIndex();
+ /**
+ * Set the Presence index
+ * @param index The Presence index
+ * @throws Exception If the addition failed
+ */
void setPresenceIndex( Index<String,E> index ) throws Exception;
+ /**
+ * @return The OneLevel system index
+ */
Index<Long,E> getOneLevelIndex();
+ /**
+ * Set the OneLevel index
+ * @param index The OneLevel index
+ * @throws Exception If the addition failed
+ */
void setOneLevelIndex( Index<Long,E> index ) throws Exception;
+ /**
+ * @return The SubLevel system index
+ */
Index<Long,E> getSubLevelIndex();
+ /**
+ * Set the SubLevel index
+ * @param index The SubLevel index
+ * @throws Exception If the addition failed
+ */
void setSubLevelIndex( Index<Long,E> index ) throws Exception;
+ /**
+ * @return The Alias system index
+ */
Index<String,E> getAliasIndex();
+ /**
+ * Set the Alias index
+ * @param index The Alias index
+ * @throws Exception If the addition failed
+ */
void setAliasIndex( Index<String,E> index ) throws Exception;
+ /**
+ * @return The OneAlias system index
+ */
Index<Long,E> getOneAliasIndex();
+ /**
+ * Set the OneAlias index
+ * @param index The OneAlias index
+ * @throws Exception If the addition failed
+ */
void setOneAliasIndex( Index<Long,E> index ) throws Exception;
+ /**
+ * @return The SubAlias system index
+ */
Index<Long,E> getSubAliasIndex();
+ /**
+ * Set the SubAlias index
+ * @param index The SubAlias index
+ * @throws Exception If the addition failed
+ */
void setSubAliasIndex( Index<Long,E> index ) throws Exception;
+ /**
+ * @return The UpDN system index
+ */
Index<String,E> getUpdnIndex();
+ /**
+ * Set the UpDn index
+ * @param index The UpDn index
+ * @throws Exception If the addition failed
+ */
void setUpdnIndex( Index<String,E> index ) throws Exception;
+ /**
+ * @return The Ndn system index
+ */
Index<String,E> getNdnIndex();
+ /**
+ * Set the NDN index
+ * @param index The NDN index
+ * @throws Exception If the addition failed
+ */
void setNdnIndex( Index<String,E> index ) throws Exception;
+ /**
+ * @return The ObjectClass system index
+ */
+ Index<String,E> getObjectClassIndex();
+
+ /**
+ * Set the ObjectClass index
+ * @param index The ObjectClass index
+ * @throws Exception If the addition failed
+ */
+ void setObjectClassIndex( Index<String,E> index ) throws Exception;
+
+
+ /**
+ * @return The EntryUUID system index
+ */
+ Index<byte[],E> getEntryUuidIndex();
+
+ /**
+ * Set the EntryUUID index
+ * @param index The EntryUUID index
+ * @throws Exception If the addition failed
+ */
+ void setEntryUuidIndex( Index<byte[],E> index ) throws Exception;
+
+
+ /**
+ * @return The EntryCSN system index
+ */
+ Index<String,E> getEntryCsnIndex();
+
+ /**
+ * Set the EntryCSN index
+ * @param index The EntryCSN index
+ * @throws Exception If the addition failed
+ */
+ void setEntryCsnIndex( Index<String,E> index ) throws Exception;
+
+ //------------------------------------------------------------------------
+ // End of the system index
+ //------------------------------------------------------------------------
+
+ /**
+ * An iterator build on top of the User's index
+ */
Iterator<String> userIndices();
+ /**
+ * An iterator build on top of the System's index
+ */
Iterator<String> systemIndices();
+ /**
+ * Tells if an index is already present in the User's index list
+ * @param id The index we are looking for
+ * @return <code>true</code> if the index is already present in the
+ * User's index list
+ * @throws Exception If something went wrong
+ */
boolean hasUserIndexOn( String id ) throws Exception;
+ /**
+ * Tells if an index is already present in the System's index list
+ * @param id The index we are looking for
+ * @return <code>true</code> if the index is already present in the
+ * System's index list
+ * @throws Exception If something went wrong
+ */
boolean hasSystemIndexOn( String id ) throws Exception;
+ /**
+ * Get the user index associated with the given name
+ * @param id The index name we are looking for
+ * @return The associated user index
+ * @throws IndexNotFoundException If the index does not exist
+ */
Index<?,E> getUserIndex( String id ) throws IndexNotFoundException;
+ /**
+ * Get the user index associated with the given name
+ * @param id The index name we are looking for
+ * @return The associated user index
+ * @throws IndexNotFoundException If the index does not exist
+ */
Index<?,E> getSystemIndex( String id ) throws IndexNotFoundException;
@@ -273,6 +455,11 @@
ServerEntry lookup( Long id ) throws Exception;
+ /**
+ * Delete the entry associated with a given Id
+ * @param id The id of the entry to delete
+ * @throws Exception If the deletion failed
+ */
void delete( Long id ) throws Exception;
Modified: directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java?rev=780299&r1=780298&r2=780299&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java (original)
+++ directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/xdbm/tools/StoreUtils.java Sat May 30 17:10:05 2009
@@ -21,7 +21,9 @@
import java.util.Set;
+import java.util.UUID;
+import org.apache.directory.server.constants.ApacheSchemaConstants;
import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerEntry;
import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
@@ -30,12 +32,14 @@
import org.apache.directory.server.xdbm.Index;
import org.apache.directory.server.xdbm.IndexEntry;
import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.shared.ldap.csn.CSNFactory;
import org.apache.directory.shared.ldap.cursor.Cursor;
import org.apache.directory.shared.ldap.entry.Entry;
import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.util.StringTools;
/**
@@ -46,6 +50,8 @@
*/
public class StoreUtils
{
+ /** CSN factory instance */
+ private static final CSNFactory CSN_FACTORY = new CSNFactory();
/**
* Initializes and loads a store with the example data shown in
@@ -76,7 +82,7 @@
entry.add( "o", "Good Times Co." );
entry.add( "postalCode", "1" );
entry.add( "postOfficeBox", "1" );
- store.add( entry );
+ injectEntryInStore( store, entry );
// Entry #2
@@ -87,7 +93,7 @@
entry.add( "ou", "Sales" );
entry.add( "postalCode", "1" );
entry.add( "postOfficeBox", "1" );
- store.add( entry );
+ injectEntryInStore( store, entry );
// Entry #3
dn = new LdapDN( "ou=Board of Directors,o=Good Times Co." );
@@ -97,7 +103,7 @@
entry.add( "ou", "Board of Directors" );
entry.add( "postalCode", "1" );
entry.add( "postOfficeBox", "1" );
- store.add( entry );
+ injectEntryInStore( store, entry );
// Entry #4
dn = new LdapDN( "ou=Engineering,o=Good Times Co." );
@@ -107,7 +113,7 @@
entry.add( "ou", "Engineering" );
entry.add( "postalCode", "2" );
entry.add( "postOfficeBox", "2" );
- store.add( entry );
+ injectEntryInStore( store, entry );
// Entry #5
dn = new LdapDN( "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
@@ -119,7 +125,7 @@
entry.add( "sn", "WAlkeR");
entry.add( "postalCode", "3" );
entry.add( "postOfficeBox", "3" );
- store.add( entry );
+ injectEntryInStore( store, entry );
// Entry #6
dn = new LdapDN( "cn=JIM BEAN,ou=Sales,o=Good Times Co." );
@@ -131,7 +137,7 @@
entry.add( "surName", "BEAN");
entry.add( "postalCode", "4" );
entry.add( "postOfficeBox", "4" );
- store.add( entry );
+ injectEntryInStore( store, entry );
// Entry #7
dn = new LdapDN( "ou=Apache,ou=Board of Directors,o=Good Times Co." );
@@ -141,7 +147,7 @@
entry.add( "ou", "Apache" );
entry.add( "postalCode", "5" );
entry.add( "postOfficeBox", "5" );
- store.add( entry );
+ injectEntryInStore( store, entry );
// Entry #8
dn = new LdapDN( "cn=Jack Daniels,ou=Engineering,o=Good Times Co." );
@@ -153,7 +159,7 @@
entry.add( "SN", "Daniels");
entry.add( "postalCode", "6" );
entry.add( "postOfficeBox", "6" );
- store.add( entry );
+ injectEntryInStore( store, entry );
// aliases -------------
@@ -165,7 +171,7 @@
entry.add( "ou", "Apache" );
entry.add( "commonName", "Jim Bean");
entry.add( "aliasedObjectName", "cn=Jim Bean,ou=Sales,o=Good Times Co." );
- store.add( entry );
+ injectEntryInStore( store, entry );
// Entry #10
dn = new LdapDN( "commonName=Jim Bean,ou=Board of Directors,o=Good Times Co." );
@@ -174,7 +180,7 @@
entry.add( "objectClass", "top", "alias", "extensibleObject" );
entry.add( "commonName", "Jim Bean");
entry.add( "aliasedObjectName", "cn=Jim Bean,ou=Sales,o=Good Times Co." );
- store.add( entry );
+ injectEntryInStore( store, entry );
// Entry #11
dn = new LdapDN( "2.5.4.3=Johnny Walker,ou=Engineering,o=Good Times Co." );
@@ -184,7 +190,7 @@
entry.add( "ou", "Engineering" );
entry.add( "2.5.4.3", "Johnny Walker");
entry.add( "aliasedObjectName", "cn=Johnny Walker,ou=Sales,o=Good Times Co." );
- store.add( entry );
+ injectEntryInStore( store, entry );
}
@@ -243,7 +249,7 @@
while ( list.next() )
{
IndexEntry rec = list.get();
- val.append( "_existance[" );
+ val.append( "_existence[" );
val.append( rec.getValue().toString() );
val.append( "]" );
@@ -279,4 +285,22 @@
return entry;
}
+
+ /**
+ *
+ * adds a given <i>ServerEntry</i> to the store after injecting entryCSN and entryUUID operational
+ * attributes
+ *
+ * @param store the store
+ * @param dn the normalized DN
+ * @param entry the server entry
+ * @throws Exception in case of any problems in adding the entry to the store
+ */
+ public static void injectEntryInStore( Store<ServerEntry> store, ServerEntry entry ) throws Exception
+ {
+ entry.add( ApacheSchemaConstants.ENTRY_CSN_AT, CSN_FACTORY.newInstance( 1 ).toString() );
+ entry.add( ApacheSchemaConstants.ENTRY_UUID_AT, StringTools.getBytesUtf8( UUID.randomUUID().toString() ) );
+
+ store.add( entry );
+ }
}
Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSN.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSN.java?rev=780299&r1=780298&r2=780299&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSN.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/csn/CSN.java Sat May 30 17:10:05 2009
@@ -265,7 +265,7 @@
}
csnStr = value;
- bytes = toBytes();
+ bytes = StringTools.getBytesUtf8( csnStr );
}
@@ -404,7 +404,7 @@
changeCount = csn.changeCount;
replicaId = csn.replicaId;
operationNumber = csn.operationNumber;
- bytes = toBytes();
+ bytes = StringTools.getBytesUtf8( csnStr );
}
@@ -414,16 +414,18 @@
* bytes 9 to 12 : change count, big endian
* bytes 13 to ... : ReplicaId
*
- * @return A byte array representing theCSN
+ * @return A copy of the byte array representing theCSN
*/
- public byte[] toBytes()
+ public byte[] getBytes()
{
if ( bytes == null )
{
bytes = StringTools.getBytesUtf8( csnStr );
}
- return bytes;
+ byte[] copy = new byte[bytes.length];
+ System.arraycopy( bytes, 0, copy, 0, bytes.length );
+ return copy;
}
@@ -481,21 +483,21 @@
long millis = (timestamp % 1000 ) * 1000;
String millisStr = Long.toString( millis );
- buf.append( '.' ).append( PADDING_3[ millisStr.length() ] ).append( millisStr ).append( "000Z#" );
+ buf.append( '.' ).append( PADDING_6[ millisStr.length() - 1 ] ).append( millisStr ).append( "Z#" );
String countStr = Integer.toHexString( changeCount );
- buf.append( PADDING_6[countStr.length()] ).append( countStr );
+ buf.append( PADDING_6[countStr.length() - 1] ).append( countStr );
buf.append( '#' );
String replicaIdStr = Integer.toHexString( replicaId );
- buf.append( PADDING_3[replicaIdStr.length()] ).append( replicaIdStr );
+ buf.append( PADDING_3[replicaIdStr.length() - 1]).append( replicaIdStr );
buf.append( '#' );
String operationNumberStr = Integer.toHexString( operationNumber );
- buf.append( PADDING_6[operationNumberStr.length()] ).append( operationNumberStr );
+ buf.append( PADDING_6[operationNumberStr.length() - 1] ).append( operationNumberStr );
csnStr = buf.toString();
}
Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNTest.java?rev=780299&r1=780298&r2=780299&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNTest.java (original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/csn/CSNTest.java Sat May 30 17:10:05 2009
@@ -322,7 +322,7 @@
{
CSN csn = new CSN( "20010101000000.000000Z#000000#abc#000001" );
- byte[] bytes = csn.toBytes();
+ byte[] bytes = csn.getBytes();
byte[] expected = new byte[]
{