You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/11/28 21:52:59 UTC
svn commit: r599142 - in /directory/apacheds/branches/bigbang:
bootstrap-plugin/
core-constants/src/main/java/org/apache/directory/server/constants/
core-unit/src/main/java/org/apache/directory/server/core/unit/
core-unit/src/test/java/org/apache/direc...
Author: akarasulu
Date: Wed Nov 28 12:52:57 2007
New Revision: 599142
URL: http://svn.apache.org/viewvc?rev=599142&view=rev
Log:
Changes made to changelog feature:
o Moved revert() into DirectoryService from ChangeLog
o ChangeLog non-null by default yet the service is off
o Interceptor included by default yet disabled
o Implemented add and delete revert() capabilities
o Added some tests to revert adds and deletes
o Started working on AbstractTestCase to revert if changelog is enabled
o Fixed serious interceptor issue with replication and mitosis based
tombstoning of deleted entries
o Fixed some issues with pom files and dependencies around constants
in the core.
Added:
directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/
directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java
Modified:
directory/apacheds/branches/bigbang/bootstrap-plugin/pom.xml
directory/apacheds/branches/bigbang/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java
directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java
directory/apacheds/branches/bigbang/core/pom.xml
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLog.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/DefaultChangeLog.java
directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java
directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
directory/apacheds/branches/bigbang/jdbm-store/pom.xml
directory/apacheds/branches/bigbang/schema-bootstrap/pom.xml
directory/apacheds/branches/bigbang/utils/pom.xml
Modified: directory/apacheds/branches/bigbang/bootstrap-plugin/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/bootstrap-plugin/pom.xml?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/bootstrap-plugin/pom.xml (original)
+++ directory/apacheds/branches/bigbang/bootstrap-plugin/pom.xml Wed Nov 28 12:52:57 2007
@@ -59,7 +59,7 @@
<dependency>
<groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-constants</artifactId>
+ <artifactId>apacheds-core-constants</artifactId>
<version>${pom.version}</version>
</dependency>
Modified: directory/apacheds/branches/bigbang/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java (original)
+++ directory/apacheds/branches/bigbang/core-constants/src/main/java/org/apache/directory/server/constants/ApacheSchemaConstants.java Wed Nov 28 12:52:57 2007
@@ -112,8 +112,11 @@
// ApacheNdn
String APACHE_ALIAS_AT = "apacheAlias";
String APACHE_ALIAS_OID = "1.3.6.1.4.1.18060.0.4.1.2.7";
-
-
+
+ // entryDeleted
+ String ENTRY_DELETED_AT = "entryDeleted";
+ String ENTRY_DELETED_OID = "1.3.6.1.4.1.18060.0.4.1.2.31";
+
// SchemaModifiersName
String SCHEMA_MODIFIERS_NAME_AT = "schemaModifiersName";
String SCHEMA_MODIFIERS_NAME_AT_OID = "";
Modified: directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java (original)
+++ directory/apacheds/branches/bigbang/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractTestCase.java Wed Nov 28 12:52:57 2007
@@ -24,6 +24,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.directory.server.core.DefaultDirectoryService;
import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.changelog.Tag;
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.ldif.Entry;
import org.apache.directory.shared.ldap.ldif.LdifReader;
@@ -98,6 +99,13 @@
private Hashtable<String,Object> overrides = new Hashtable<String,Object>();
+ /**
+ * The revision at which a test was begun and the revision we will revert
+ * to if the change log is enabled by the user. If the change log is
+ * disabled this is field is ignored and will remain null.
+ */
+ private Tag startTag;
+
protected Registries registries;
protected DirectoryService service;
@@ -151,6 +159,22 @@
protected void setUp() throws Exception
{
super.setUp();
+
+ // -------------------------------------------------------------------
+ // Bypass normal startup if changelog has been enabled and the server
+ // has already started.
+ // -------------------------------------------------------------------
+
+ /// still working on it!!!
+// if ( service.getChangeLog().isEnabled() )
+// {
+// startTag = service.getChangeLog().tag();
+//
+// if ( service.isStarted() )
+// {
+// return;
+// }
+// }
// -------------------------------------------------------------------
// Add a single test entry
Added: directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java?rev=599142&view=auto
==============================================================================
--- directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java (added)
+++ directory/apacheds/branches/bigbang/core-unit/src/test/java/org/apache/directory/server/core/changelog/DefaultChangeLogITest.java Wed Nov 28 12:52:57 2007
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.directory.server.core.changelog;
+
+
+import org.apache.directory.server.core.unit.AbstractTestCase;
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+
+
+/**
+ * Used to test the default change log implementation with an in memory
+ * change log store. Note that this will probably be removed since this
+ * functionality will be used and tested anyway in all other test cases.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DefaultChangeLogITest extends AbstractTestCase
+{
+ /**
+ * Can go away once we remove the need for authentication in super class.
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/DIRSERVER-1105">DIRSERVER-1105<a/>
+ */
+ public DefaultChangeLogITest()
+ {
+ super( "uid=admin,ou=system", "secret" );
+ }
+
+
+ public void setUp() throws Exception
+ {
+ service.getChangeLog().setEnabled( true );
+ super.setUp();
+ }
+
+
+ public void testRevertAddOperations() throws NamingException
+ {
+ Tag t0 = service.getChangeLog().tag();
+ AttributesImpl attrs = new AttributesImpl( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test" );
+ sysRoot.createSubcontext( "ou=test", attrs );
+
+ assertNotNull( sysRoot.getAttributes( "ou=test" ) );
+ service.revert( t0.getRevision() );
+
+ try
+ {
+ sysRoot.getAttributes( "ou=test" );
+ fail( "Should not be able to find the entry!" );
+ }
+ catch ( NamingException ne )
+ {
+ assertTrue( ne instanceof LdapNameNotFoundException );
+ }
+ }
+
+
+ public void testRevertAddAndDeleteOperations() throws NamingException
+ {
+ Tag t0 = service.getChangeLog().tag();
+
+ // add new test entry
+ AttributesImpl attrs = new AttributesImpl( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test" );
+ sysRoot.createSubcontext( "ou=test", attrs );
+
+ // assert presence
+ assertNotNull( sysRoot.getAttributes( "ou=test" ) );
+
+ // delete the test entry and test that it is gone
+ sysRoot.destroySubcontext( "ou=test" );
+ assertNotPresent( sysRoot, "ou=test" );
+
+ // now revert back to begining the added entry is still gone
+ service.revert( t0.getRevision() );
+ assertNotPresent( sysRoot, "ou=test" );
+ }
+
+
+ public void testRevertDeleteOperations() throws NamingException
+ {
+ AttributesImpl attrs = new AttributesImpl( "objectClass", "organizationalUnit", true );
+ attrs.put( "ou", "test" );
+ sysRoot.createSubcontext( "ou=test", attrs );
+
+ // tag after the addition before deletion
+ Tag t0 = service.getChangeLog().tag();
+ assertNotNull( sysRoot.getAttributes( "ou=test" ) );
+
+ // delete the test entry and test that it is gone
+ sysRoot.destroySubcontext( "ou=test" );
+ assertNotPresent( sysRoot, "ou=test" );
+
+ // now revert and assert that the added entry re-appears
+ service.revert( t0.getRevision() );
+ assertNotNull( sysRoot.getAttributes( "ou=test" ) );
+ }
+
+
+ private void assertNotPresent( DirContext ctx, String dn ) throws NamingException
+ {
+ try
+ {
+ ctx.getAttributes( dn );
+ fail( "Should not be able to find the entry " + dn + " but it is still there." );
+ }
+ catch ( NamingException ne )
+ {
+ assertTrue( ne instanceof LdapNameNotFoundException );
+ }
+ }
+}
Modified: directory/apacheds/branches/bigbang/core/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/pom.xml?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/pom.xml (original)
+++ directory/apacheds/branches/bigbang/core/pom.xml Wed Nov 28 12:52:57 2007
@@ -60,19 +60,19 @@
<dependency>
<groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-utils</artifactId>
+ <artifactId>apacheds-core-constants</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-jdbm-store</artifactId>
+ <artifactId>apacheds-utils</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency>
<groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-constants</artifactId>
+ <artifactId>apacheds-jdbm-store</artifactId>
<version>${pom.version}</version>
</dependency>
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Wed Nov 28 12:52:57 2007
@@ -25,8 +25,11 @@
import org.apache.directory.server.core.authz.AciAuthorizationInterceptor;
import org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor;
import org.apache.directory.server.core.changelog.ChangeLog;
+import org.apache.directory.server.core.changelog.ChangeLogEvent;
+import org.apache.directory.server.core.changelog.ChangeLogInterceptor;
import org.apache.directory.server.core.changelog.DefaultChangeLog;
import org.apache.directory.server.core.collective.CollectiveAttributeInterceptor;
+import org.apache.directory.server.core.cursor.Cursor;
import org.apache.directory.server.core.event.EventInterceptor;
import org.apache.directory.server.core.exception.ExceptionInterceptor;
import org.apache.directory.server.core.interceptor.Interceptor;
@@ -58,6 +61,7 @@
import org.apache.directory.server.schema.registries.DefaultRegistries;
import org.apache.directory.server.schema.registries.OidRegistry;
import org.apache.directory.server.schema.registries.Registries;
+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.constants.ServerDNConstants;
@@ -65,6 +69,7 @@
import org.apache.directory.shared.ldap.exception.LdapConfigurationException;
import org.apache.directory.shared.ldap.exception.LdapNamingException;
import org.apache.directory.shared.ldap.exception.LdapNoPermissionException;
+import org.apache.directory.shared.ldap.ldif.ChangeType;
import org.apache.directory.shared.ldap.ldif.Entry;
import org.apache.directory.shared.ldap.message.AttributeImpl;
import org.apache.directory.shared.ldap.message.AttributesImpl;
@@ -115,6 +120,12 @@
/** the change log service */
private ChangeLog changeLog;
+ /** remove me after implementation is completed */
+ private static final String PARTIAL_IMPL_WARNING =
+ "WARNING: the changelog is only partially operational and will revert\n" +
+ "state without consideration of who made the original change. All reverting " +
+ "changes are made by the admin user.\n Furthermore the used controls are not at " +
+ "all taken into account";
// ------------------------------------------------------------------------
// Constructor
@@ -474,6 +485,7 @@
list.add( new AciAuthorizationInterceptor() );
list.add( new DefaultAuthorizationInterceptor() );
list.add( new ExceptionInterceptor() );
+ list.add( new ChangeLogInterceptor() );
list.add( new OperationalAttributeInterceptor() );
list.add( new SchemaInterceptor() );
list.add( new SubentryInterceptor() );
@@ -548,6 +560,70 @@
environment.put( DirectoryService.JNDI_KEY, this );
return new ServerLdapContext( this, environment );
+ }
+
+
+ public long revert( long revision ) throws NamingException
+ {
+ if ( changeLog == null || ! changeLog.isEnabled() )
+ {
+ throw new IllegalStateException( "The change log must be enabled to revert to previous log revisions." );
+ }
+
+ if ( revision < 0 )
+ {
+ throw new IllegalArgumentException( "revision must be greater than or equal to 0" );
+ }
+
+ if ( revision >= changeLog.getChangeLogStore().getCurrentRevision() )
+ {
+ throw new IllegalArgumentException( "revision must be less than the current revision" );
+ }
+
+ DirContext ctx = getJndiContext( new LdapPrincipal( new LdapDN( "uid=admin,ou=system" ),
+ AuthenticationLevel.SIMPLE ) );
+ Cursor<ChangeLogEvent> cursor = changeLog.getChangeLogStore().findAfter( revision );
+
+ /*
+ * BAD, BAD, BAD!!!
+ *
+ * No synchronization no nothing. Just getting this to work for now
+ * so we can revert tests. Any production grade use of this feature
+ * needs to synchronize on all changes while the revert is in progress.
+ *
+ * How about making this operation transactional?
+ */
+
+ try
+ {
+ LOG.warn( PARTIAL_IMPL_WARNING );
+ cursor.afterLast();
+ while ( cursor.previous() ) // apply ldifs in reverse order
+ {
+ ChangeLogEvent event = cursor.get();
+ Entry reverse = event.getReverseLdif();
+
+ switch( reverse.getChangeType().getChangeType() )
+ {
+ case( ChangeType.ADD_ORDINAL ):
+ ctx.createSubcontext( reverse.getDn(), reverse.getAttributes() );
+ break;
+ case( ChangeType.DELETE_ORDINAL ):
+ ctx.destroySubcontext( reverse.getDn() );
+ break;
+ default:
+ throw new NotImplementedException( "Reverts of change type " + reverse.getChangeType()
+ + " has not yet been implemented!");
+ }
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new NamingException( "Encountered a failure while trying to revert to a previous revision: "
+ + revision );
+ }
+
+ return changeLog.getCurrentRevision();
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/DirectoryService.java Wed Nov 28 12:52:57 2007
@@ -51,19 +51,44 @@
{
String JNDI_KEY = DirectoryService.class.getName();
+ /**
+ * Reverts the server's state to an earlier revision. Note that the revsion number
+ * still increases to revert back even though the state reverted to is the same.
+ * Note that implementations may lock the server from making changes or searching
+ * the directory until this operation has completed.
+ *
+ * @param revision the revision number to revert to
+ * @return the new revision reached by applying all changes needed to revert to the
+ * original state
+ * @throws NamingException if there are problems reverting back to the earlier state
+ * @throws IllegalArgumentException if the revision provided is greater than the current
+ * revision or less than 0
+ * @throws UnsupportedOperationException if this feature is not supported by the
+ * change log
+ */
+ long revert( long revision ) throws NamingException;
+
+
PartitionNexus getPartitionNexus();
+
InterceptorChain getInterceptorChain();
+
void addPartition( Partition partition ) throws NamingException;
+
void removePartition( Partition partition ) throws NamingException;
+
Registries getRegistries();
+
void setRegistries( Registries registries );
+
SchemaManager getSchemaManager();
+
void setSchemaManager( SchemaManager schemaManager );
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLog.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLog.java?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLog.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLog.java Wed Nov 28 12:52:57 2007
@@ -44,6 +44,15 @@
boolean isEnabled();
+ void setEnabled( boolean enabled );
+
+
+ ChangeLogStore getChangeLogStore();
+
+
+ void setChangeLogStore( ChangeLogStore store );
+
+
/**
* Gets the current revision for the server.
*
@@ -161,22 +170,4 @@
* @throws NamingException if there is a problem taking a tag
*/
Tag tag() throws NamingException;
-
-
- /**
- * Reverts the server's state to an earlier revision. Note that the revsion number
- * still increases to revert back even though the state reverted to is the same.
- * Note that implementations may lock the server from making changes or searching
- * the directory until this operation has completed.
- *
- * @param revision the revision number to revert to
- * @return the new revision reached by applying all changes needed to revert to the
- * original state
- * @throws NamingException if there are problems reverting back to the earlier state
- * @throws IllegalArgumentException if the revision provided is greater than the current
- * revision or less than 0
- * @throws UnsupportedOperationException if this feature is not supported by the
- * change log
- */
- long revert( long revision ) throws NamingException;
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java Wed Nov 28 12:52:57 2007
@@ -19,6 +19,7 @@
package org.apache.directory.server.core.changelog;
+import org.apache.directory.server.constants.ApacheSchemaConstants;
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.interceptor.BaseInterceptor;
import org.apache.directory.server.core.interceptor.NextInterceptor;
@@ -31,6 +32,10 @@
import org.apache.directory.shared.ldap.ldif.LdifUtils;
import org.apache.directory.shared.ldap.message.ModificationItemImpl;
import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -44,6 +49,10 @@
*/
public class ChangeLogInterceptor extends BaseInterceptor
{
+ /** for debugging */
+ private static final Logger LOG = LoggerFactory.getLogger( ChangeLogInterceptor.class );
+ /** used to ignore modify operations to tombstone entries */
+ private AttributeType entryDeleted;
/** the changelog service to log changes to */
private ChangeLog changeLog;
@@ -57,6 +66,9 @@
{
super.init( directoryService );
changeLog = directoryService.getChangeLog();
+
+ entryDeleted = directoryService.getRegistries().getAttributeTypeRegistry()
+ .lookup( ApacheSchemaConstants.ENTRY_DELETED_OID );
}
@@ -92,6 +104,18 @@
*/
public void delete( NextInterceptor next, DeleteOperationContext opContext ) throws NamingException
{
+ // @todo make sure we're not putting in operational attributes that cannot be user modified
+ // must save the entry if change log is enabled
+ Attributes attributes = null;
+
+ if ( changeLog.isEnabled() )
+ {
+ Invocation invocation = InvocationStack.getInstance().peek();
+ PartitionNexusProxy proxy = invocation.getProxy();
+ attributes = proxy.lookup( new LookupOperationContext( opContext.getDn() ),
+ PartitionNexusProxy.LOOKUP_BYPASS );
+ }
+
next.delete( opContext );
if ( ! changeLog.isEnabled() )
@@ -99,12 +123,6 @@
return;
}
- // @todo make sure we're not putting in operational attributes that cannot be user modified
- Invocation invocation = InvocationStack.getInstance().peek();
- PartitionNexusProxy proxy = invocation.getProxy();
- Attributes attributes = proxy.lookup( new LookupOperationContext( opContext.getDn() ),
- PartitionNexusProxy.LOOKUP_BYPASS );
-
Entry forward = new Entry();
forward.setChangeType( ChangeType.Delete );
forward.setDn( opContext.getDn().getUpName() );
@@ -116,6 +134,14 @@
public void modify( NextInterceptor next, ModifyOperationContext opContext ) throws NamingException
{
next.modify( opContext );
+
+ // @TODO: needs big consideration!!!
+ // NOTE: perhaps we need to log this as a system operation that cannot and should not be reapplied?
+ if ( AttributeUtils.getAttribute( opContext.getModItems(), entryDeleted ) != null )
+ {
+ LOG.debug( "Bypassing changelog on modify of entryDeleted attribute." );
+ return;
+ }
if ( ! changeLog.isEnabled() )
{
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/DefaultChangeLog.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/DefaultChangeLog.java?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/DefaultChangeLog.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/DefaultChangeLog.java Wed Nov 28 12:52:57 2007
@@ -19,9 +19,8 @@
package org.apache.directory.server.core.changelog;
-import org.apache.directory.shared.ldap.NotImplementedException;
-import org.apache.directory.shared.ldap.ldif.Entry;
import org.apache.directory.server.core.authn.LdapPrincipal;
+import org.apache.directory.shared.ldap.ldif.Entry;
import javax.naming.NamingException;
@@ -29,13 +28,15 @@
/**
* The default ChangeLog service implementation.
*
+ * @org.apache.xbean.XBean
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class DefaultChangeLog implements ChangeLog
{
private boolean enabled;
- private ChangeLogStore store;
+ private ChangeLogStore store = new MemoryChangeLogStore();
public ChangeLogStore getChangeLogStore()
@@ -116,7 +117,7 @@
throw new IllegalArgumentException( "revision must be greater than or equal to 0" );
}
- if ( revision <= store.getCurrentRevision() )
+ if ( revision > store.getCurrentRevision() )
{
throw new IllegalArgumentException( "revision must be less than or equal to the current revision" );
}
@@ -145,22 +146,6 @@
public Tag tag() throws NamingException
{
return tag( store.getCurrentRevision(), null );
- }
-
-
- public long revert( long revision ) throws NamingException
- {
- if ( revision < 0 )
- {
- throw new IllegalArgumentException( "revision must be greater than or equal to 0" );
- }
-
- if ( revision >= store.getCurrentRevision() )
- {
- throw new IllegalArgumentException( "revision must be less than the current revision" );
- }
-
- throw new NotImplementedException();
}
Modified: directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java (original)
+++ directory/apacheds/branches/bigbang/core/src/main/java/org/apache/directory/server/core/changelog/MemoryChangeLogStore.java Wed Nov 28 12:52:57 2007
@@ -34,6 +34,8 @@
/**
* A change log store that keeps it's information in memory.
*
+ * @org.apache.xbean.XBean
+ *
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
@@ -46,7 +48,12 @@
public Tag tag( long revision ) throws NamingException
{
- return tags.get( revision );
+ if ( tags.containsKey( revision ) )
+ {
+ return tags.get( revision );
+ }
+
+ return new Tag( revision, null );
}
@@ -110,7 +117,7 @@
public Cursor<ChangeLogEvent> findAfter( long revision ) throws NamingException
{
- return new ListCursor<ChangeLogEvent>( ( int ) ( revision + 1 ), events );
+ return new ListCursor<ChangeLogEvent>( ( int ) revision, events );
}
Modified: directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java (original)
+++ directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/authz/support/MaxImmSubFilterTest.java Wed Nov 28 12:52:57 2007
@@ -193,6 +193,12 @@
}
+ public long revert( long revision ) throws NamingException
+ {
+ return 0;
+ }
+
+
public PartitionNexus getPartitionNexus()
{
return null;
Modified: directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java (original)
+++ directory/apacheds/branches/bigbang/core/src/test/java/org/apache/directory/server/core/interceptor/InterceptorChainTest.java Wed Nov 28 12:52:57 2007
@@ -256,6 +256,12 @@
}
+ public long revert( long revision ) throws NamingException
+ {
+ return 0;
+ }
+
+
public PartitionNexus getPartitionNexus()
{
return null;
Modified: directory/apacheds/branches/bigbang/jdbm-store/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/pom.xml?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/pom.xml (original)
+++ directory/apacheds/branches/bigbang/jdbm-store/pom.xml Wed Nov 28 12:52:57 2007
@@ -51,7 +51,7 @@
<dependency>
<groupId>${pom.groupId}</groupId>
- <artifactId>apacheds-constants</artifactId>
+ <artifactId>apacheds-core-constants</artifactId>
<version>${pom.version}</version>
</dependency>
Modified: directory/apacheds/branches/bigbang/schema-bootstrap/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/schema-bootstrap/pom.xml?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/schema-bootstrap/pom.xml (original)
+++ directory/apacheds/branches/bigbang/schema-bootstrap/pom.xml Wed Nov 28 12:52:57 2007
@@ -48,7 +48,7 @@
<dependency>
<groupId>org.apache.directory.server</groupId>
- <artifactId>apacheds-constants</artifactId>
+ <artifactId>apacheds-core-constants</artifactId>
<version>${pom.version}</version>
</dependency>
Modified: directory/apacheds/branches/bigbang/utils/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/utils/pom.xml?rev=599142&r1=599141&r2=599142&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/utils/pom.xml (original)
+++ directory/apacheds/branches/bigbang/utils/pom.xml Wed Nov 28 12:52:57 2007
@@ -34,7 +34,7 @@
<dependencies>
<dependency>
<groupId>${pom.groupId}</groupId>
- <artifactId>apacheds-constants</artifactId>
+ <artifactId>apacheds-core-constants</artifactId>
<version>${pom.version}</version>
</dependency>