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/09/24 08:38:23 UTC
svn commit: r818377 - in /directory/apacheds/branches/apacheds-schema:
core-api/src/main/java/org/apache/directory/server/core/interceptor/context/
core-api/src/main/java/org/apache/directory/server/core/schema/
core-integ/src/test/java/org/apache/dire...
Author: elecharny
Date: Thu Sep 24 06:38:22 2009
New Revision: 818377
URL: http://svn.apache.org/viewvc?rev=818377&view=rev
Log:
o Fixes for the rename operation
o Many cleanups in the interceptors (removed useless lookup, clonings and DN manipulations)
Modified:
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/RenameOperationContext.java
directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java
directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceIT.java
directory/apacheds/branches/apacheds-schema/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java
directory/apacheds/branches/apacheds-schema/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/RenameOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/RenameOperationContext.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/RenameOperationContext.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/RenameOperationContext.java Thu Sep 24 06:38:22 2009
@@ -22,8 +22,8 @@
import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.core.entry.ClonedServerEntry;
-import org.apache.directory.shared.ldap.message.MessageTypeEnum;
import org.apache.directory.shared.ldap.message.InternalModifyDnRequest;
+import org.apache.directory.shared.ldap.message.MessageTypeEnum;
import org.apache.directory.shared.ldap.message.control.ManageDsaITControl;
import org.apache.directory.shared.ldap.name.LdapDN;
import org.apache.directory.shared.ldap.name.Rdn;
@@ -125,15 +125,6 @@
*/
public LdapDN getNewDn() throws Exception
{
- if ( newDn == null )
- {
- newDn = new LdapDN( getDn().getUpName() );
- newDn.remove( newDn.size() - 1 );
- newDn.add( newRdn.getUpName() );
- newDn.normalize( session.getDirectoryService().getRegistries()
- .getAttributeTypeRegistry().getNormalizerMapping() );
- }
-
return newDn;
}
@@ -158,6 +149,16 @@
/**
+ * Set the new DN
+ * @param newDn The new DN
+ */
+ public void setNewDn( LdapDN newDn )
+ {
+ this.newDn = newDn;
+ }
+
+
+ /**
* @return the operation name
*/
public String getName()
Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java Thu Sep 24 06:38:22 2009
@@ -471,10 +471,7 @@
registries.getAttributeTypeRegistry().lookup( ApacheSchemaConstants.SCHEMA_MODIFIERS_NAME_AT ),
modifiersName ) ) );
- LdapDN name = new LdapDN( ServerDNConstants.SCHEMA_MODIFICATIONS_DN );
- name.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
-
- opContext.modify( name, mods, ByPassConstants.SCHEMA_MODIFICATION_ATTRIBUTES_UPDATE_BYPASS );
+ opContext.modify( schemaModificationDN, mods, ByPassConstants.SCHEMA_MODIFICATION_ATTRIBUTES_UPDATE_BYPASS );
}
Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceIT.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/exception/ExceptionServiceIT.java Thu Sep 24 06:38:22 2009
@@ -20,22 +20,12 @@
package org.apache.directory.server.core.exception;
-import org.apache.directory.server.core.DirectoryService;
-import org.apache.directory.server.core.integ.CiRunner;
import static org.apache.directory.server.core.integ.IntegrationUtils.getSystemContext;
-import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.exception.LdapContextNotEmptyException;
-import org.apache.directory.shared.ldap.exception.LdapNameAlreadyBoundException;
-import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
-import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import org.junit.Test;
-import org.junit.runner.RunWith;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@@ -49,6 +39,17 @@
import javax.naming.directory.SearchResult;
import javax.naming.ldap.LdapContext;
+import org.apache.directory.server.core.DirectoryService;
+import org.apache.directory.server.core.integ.CiRunner;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.exception.LdapContextNotEmptyException;
+import org.apache.directory.shared.ldap.exception.LdapNameAlreadyBoundException;
+import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
+import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
/**
* Tests the correct operation of the ServerExceptionService.
@@ -296,7 +297,7 @@
}
catch ( LdapNameNotFoundException e )
{
- assertEquals( "ou=system", e.getResolvedName().toString() );
+ assertEquals( "ou=blah,ou=system", e.getResolvedName().toString() );
assertEquals( ResultCodeEnum.NO_SUCH_OBJECT, e.getResultCode() );
}
}
Modified: directory/apacheds/branches/apacheds-schema/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Thu Sep 24 06:38:22 2009
@@ -20,12 +20,34 @@
package org.apache.directory.server.core.jndi;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Context;
+import javax.naming.InvalidNameException;
+import javax.naming.Name;
+import javax.naming.NameNotFoundException;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.Reference;
+import javax.naming.Referenceable;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.SearchControls;
+import javax.naming.event.EventContext;
+import javax.naming.event.NamingListener;
+import javax.naming.ldap.Control;
+import javax.naming.spi.DirStateFactory;
+import javax.naming.spi.DirectoryManager;
+
import org.apache.directory.server.core.CoreSession;
import org.apache.directory.server.core.DefaultCoreSession;
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.LdapPrincipal;
import org.apache.directory.server.core.OperationManager;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.entry.DefaultServerEntry;
import org.apache.directory.server.core.entry.ServerEntry;
@@ -52,6 +74,7 @@
import org.apache.directory.shared.ldap.constants.SchemaConstants;
import org.apache.directory.shared.ldap.cursor.EmptyCursor;
import org.apache.directory.shared.ldap.cursor.SingletonCursor;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
import org.apache.directory.shared.ldap.entry.Modification;
import org.apache.directory.shared.ldap.exception.LdapNoPermissionException;
import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
@@ -67,28 +90,6 @@
import org.apache.directory.shared.ldap.util.AttributeUtils;
import org.apache.directory.shared.ldap.util.StringTools;
-import javax.naming.Context;
-import javax.naming.InvalidNameException;
-import javax.naming.Name;
-import javax.naming.NameNotFoundException;
-import javax.naming.NameParser;
-import javax.naming.NamingEnumeration;
-import javax.naming.NamingException;
-import javax.naming.Reference;
-import javax.naming.Referenceable;
-import javax.naming.directory.DirContext;
-import javax.naming.directory.SearchControls;
-import javax.naming.event.EventContext;
-import javax.naming.event.NamingListener;
-import javax.naming.ldap.Control;
-import javax.naming.spi.DirStateFactory;
-import javax.naming.spi.DirectoryManager;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
/**
* A non-federated abstract Context implementation.
@@ -148,7 +149,6 @@
* @throws NamingException if the environment parameters are not set
* correctly.
*/
- @SuppressWarnings(value = { "unchecked" })
protected ServerContext( DirectoryService service, Hashtable<String, Object> env ) throws Exception
{
this.service = service;
@@ -484,7 +484,7 @@
/**
* Used to encapsulate [de]marshalling of controls before and after moveAndRename operations.
*/
- protected void doMoveAndRenameOperation( LdapDN oldDn, LdapDN parent, String newRdn, boolean delOldDn )
+ protected void doMoveAndRenameOperation( LdapDN oldDn, LdapDN parent, Rdn newRdn, boolean delOldDn )
throws Exception
{
// setup the op context and populate with request controls
@@ -552,10 +552,10 @@
/**
* Used to encapsulate [de]marshalling of controls before and after rename operations.
*/
- protected void doRename( LdapDN oldDn, String newRdn, boolean delOldRdn ) throws Exception
+ protected void doRename( LdapDN oldDn, Rdn newRdn, boolean delOldRdn ) throws Exception
{
// setup the op context and populate with request controls
- RenameOperationContext opCtx = new RenameOperationContext( session, oldDn, new Rdn( newRdn ), delOldRdn );
+ RenameOperationContext opCtx = new RenameOperationContext( session, oldDn, newRdn, delOldRdn );
opCtx.addRequestControls( requestControls );
// Inject the referral handling into the operation context
@@ -949,13 +949,13 @@
}
// calculate parents
- LdapDN oldBase = ( LdapDN ) oldName.clone();
- oldBase.remove( oldName.size() - 1 );
- LdapDN newBase = ( LdapDN ) newName.clone();
- newBase.remove( newName.size() - 1 );
+ LdapDN oldParent = (LdapDN)oldDn.clone();
+ oldParent.remove( oldDn.size() - 1 );
+ LdapDN newParent = ( LdapDN ) newDn.clone();
+ newParent.remove( newDn.size() - 1 );
- String newRdn = newName.get( newName.size() - 1 );
- String oldRdn = oldName.get( oldName.size() - 1 );
+ Rdn oldRdn = oldDn.getRdn();
+ Rdn newRdn = newDn.getRdn();
boolean delOldRdn = true;
/*
@@ -977,7 +977,7 @@
* a move operation. Furthermore if the RDN in the move operation
* changes it is both an RDN change and a move operation.
*/
- if ( ( oldName.size() == newName.size() ) && oldBase.equals( newBase ) )
+ if ( oldParent.equals( newParent ) )
{
try
{
@@ -990,14 +990,11 @@
}
else
{
- LdapDN target = ( LdapDN ) newDn.clone();
- target.remove( newDn.size() - 1 );
-
- if ( newRdn.equalsIgnoreCase( oldRdn ) )
+ if ( newRdn.equals( oldRdn ) )
{
try
{
- doMove( oldDn, target );
+ doMove( oldDn, newParent );
}
catch ( Exception e )
{
@@ -1008,7 +1005,7 @@
{
try
{
- doMoveAndRenameOperation( oldDn, target, newRdn, delOldRdn );
+ doMoveAndRenameOperation( oldDn, newParent, newRdn, delOldRdn );
}
catch ( Exception e )
{
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultCoreSession.java Thu Sep 24 06:38:22 2009
@@ -56,8 +56,8 @@
import org.apache.directory.shared.ldap.filter.ExprNode;
import org.apache.directory.shared.ldap.filter.FilterParser;
import org.apache.directory.shared.ldap.filter.SearchScope;
-import org.apache.directory.shared.ldap.message.InternalAddRequest;
import org.apache.directory.shared.ldap.message.AliasDerefMode;
+import org.apache.directory.shared.ldap.message.InternalAddRequest;
import org.apache.directory.shared.ldap.message.InternalCompareRequest;
import org.apache.directory.shared.ldap.message.InternalDeleteRequest;
import org.apache.directory.shared.ldap.message.InternalModifyDnRequest;
@@ -669,6 +669,7 @@
opContext.setLogChange( log );
OperationManager operationManager = directoryService.getOperationManager();
+
operationManager.rename( opContext );
}
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/DefaultOperationManager.java Thu Sep 24 06:38:22 2009
@@ -923,6 +923,16 @@
LdapDN dn = opContext.getDn();
dn.normalize( directoryService.getRegistries().getAttributeTypeRegistry().getNormalizerMapping() );
+ // Inject the newDn into the operation context
+ // Inject the new DN into the context
+ if ( !dn.isEmpty() )
+ {
+ LdapDN newDn = (LdapDN)dn.clone();
+ newDn.remove( dn.size() - 1 );
+ newDn.add( opContext.getNewRdn() );
+ opContext.setNewDn( newDn );
+ }
+
// We have to deal with the referral first
directoryService.getReferralManager().lockRead();
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/authz/AciAuthorizationInterceptor.java Thu Sep 24 06:38:22 2009
@@ -802,16 +802,17 @@
public void rename( NextInterceptor next, RenameOperationContext renameContext ) throws Exception
{
- LdapDN name = renameContext.getDn();
-
- ClonedServerEntry entry = renameContext.getEntry();
+ LdapDN oldName = renameContext.getDn();
+ ServerEntry originalEntry = null;
+
+ if ( renameContext.getEntry() != null )
+ {
+ originalEntry = renameContext.getEntry().getOriginalEntry();
+ }
LdapPrincipal principal = renameContext.getSession().getEffectivePrincipal();
LdapDN principalDn = principal.getJndiName();
- LdapDN newName = ( LdapDN ) name.clone();
- newName.remove( name.size() - 1 );
-
- newName.add( renameContext.getNewRdn() );
+ LdapDN newName = renameContext.getNewDn();
// bypass authz code if we are disabled
if ( !enabled )
@@ -820,33 +821,33 @@
return;
}
- protectCriticalEntries( name );
+ protectCriticalEntries( oldName );
// bypass authz code but manage caches if operation is performed by the admin
if ( isPrincipalAnAdministrator( principalDn ) )
{
next.rename( renameContext );
- tupleCache.subentryRenamed( name, newName );
+ tupleCache.subentryRenamed( oldName, newName );
// TODO : this method returns a boolean : what should we do with the result ?
- groupCache.groupRenamed( name, newName );
+ groupCache.groupRenamed( oldName, newName );
return;
}
Set<LdapDN> userGroups = groupCache.getGroups( principalDn.toString() );
Collection<ACITuple> tuples = new HashSet<ACITuple>();
- addPerscriptiveAciTuples( renameContext, tuples, name, entry.getOriginalEntry() );
- addEntryAciTuples( tuples, entry );
- addSubentryAciTuples( renameContext, tuples, name, entry );
+ addPerscriptiveAciTuples( renameContext, tuples, oldName, originalEntry );
+ addEntryAciTuples( tuples, originalEntry );
+ addSubentryAciTuples( renameContext, tuples, oldName, originalEntry );
engine.checkPermission( registries, renameContext, userGroups, principalDn,
- principal.getAuthenticationLevel(), name, null, null,
- RENAME_PERMS, tuples, entry, null );
+ principal.getAuthenticationLevel(), oldName, null, null,
+ RENAME_PERMS, tuples, originalEntry, null );
next.rename( renameContext );
- tupleCache.subentryRenamed( name, newName );
- groupCache.groupRenamed( name, newName );
+ tupleCache.subentryRenamed( oldName, newName );
+ groupCache.groupRenamed( oldName, newName );
}
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java Thu Sep 24 06:38:22 2009
@@ -287,13 +287,15 @@
{
ServerEntry serverEntry = null;
- if ( changeLog.isEnabled() && renameContext.isFirstOperation() )
+ if ( renameContext.getEntry() != null )
{
- // @todo make sure we're not putting in operational attributes that cannot be user modified
- serverEntry = getAttributes( renameContext );
+ serverEntry = renameContext.getEntry().getOriginalEntry();
}
-
+
next.rename( renameContext );
+
+ // After this point, the entry has been modified. The cloned entry contains
+ // the modified entry, the originalEntry has changed
if ( ! changeLog.isEnabled() || ! renameContext.isFirstOperation() )
{
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/event/EventInterceptor.java Thu Sep 24 06:38:22 2009
@@ -210,7 +210,7 @@
public void rename( NextInterceptor next, RenameOperationContext opContext ) throws Exception
{
- ClonedServerEntry oriEntry = opContext.getEntry();
+ ServerEntry oriEntry = opContext.getEntry().getOriginalEntry();
List<RegistrationEntry> selecting = getSelectingRegistrations( opContext.getDn(), oriEntry );
next.rename( opContext );
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Thu Sep 24 06:38:22 2009
@@ -375,7 +375,7 @@
{
LdapDN dn = opContext.getDn();
- if ( dn.getNormName().equalsIgnoreCase( subschemSubentryDn.getNormName() ) )
+ if ( dn.equals( subschemSubentryDn ) )
{
throw new LdapOperationNotSupportedException(
"Can not allow the renaming of the subschemaSubentry (" +
@@ -383,15 +383,19 @@
ResultCodeEnum.UNWILLING_TO_PERFORM );
}
- // check if entry to rename exists
- String msg = "Attempt to rename non-existant entry: ";
- assertHasEntry( nextInterceptor, opContext, msg, dn );
-
+ // Check to see if the renamed entry exists
+ if ( opContext.getEntry() == null )
+ {
+ // This is a nonsense : we can't rename an entry which does not exist
+ // on the server
+ LdapNameNotFoundException ldnfe;
+ ldnfe = new LdapNameNotFoundException( "target entry " + dn.getUpName() + " des not exist!" );
+ ldnfe.setResolvedName( new LdapDN( dn.getUpName() ) );
+ throw ldnfe;
+ }
+
// check to see if target entry exists
- LdapDN newDn = ( LdapDN ) dn.clone();
- newDn.remove( dn.size() - 1 );
- newDn.add( opContext.getNewRdn() );
- newDn.normalize( normalizerMap );
+ LdapDN newDn = opContext.getNewDn();
if ( nextInterceptor.hasEntry( new EntryOperationContext( opContext.getSession(), newDn ) ) )
{
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/normalization/NormalizationInterceptor.java Thu Sep 24 06:38:22 2009
@@ -20,11 +20,13 @@
package org.apache.directory.server.core.normalization;
+import java.util.Map;
+
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.entry.ClonedServerEntry;
import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.filtering.EntryFilteringCursor;
import org.apache.directory.server.core.filtering.BaseEntryFilteringCursor;
+import org.apache.directory.server.core.filtering.EntryFilteringCursor;
import org.apache.directory.server.core.interceptor.BaseInterceptor;
import org.apache.directory.server.core.interceptor.NextInterceptor;
import org.apache.directory.server.core.interceptor.context.AddContextPartitionOperationContext;
@@ -55,12 +57,9 @@
import org.apache.directory.shared.ldap.schema.normalizers.ConcreteNameComponentNormalizer;
import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Map;
-
/**
* A name normalization service. This service makes sure all relative and distinguished
@@ -151,12 +150,12 @@
*/
public void rename( NextInterceptor nextInterceptor, RenameOperationContext opContext ) throws Exception
{
- LdapDN rdn = new LdapDN();
- rdn.add( opContext.getNewRdn() );
- rdn.normalize( attrNormalizers );
- opContext.setNewRdn( rdn.getRdn() );
-
+ // Normalize the new RDN and the DN
+ opContext.getNewRdn().normalize( attrNormalizers );
opContext.getDn().normalize( attrNormalizers );
+ opContext.getNewDn().normalize( attrNormalizers );
+
+ // Push to the next interceptor
nextInterceptor.rename( opContext );
}
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java Thu Sep 24 06:38:22 2009
@@ -244,7 +244,6 @@
// -------------------------------------------------------------------
// Make the modify() call happen
// -------------------------------------------------------------------
-
ModifyOperationContext newModify = new ModifyOperationContext( opContext.getSession(),
opContext.getDn(), modItemList );
newModify.setEntry( opContext.getEntry() );
@@ -257,10 +256,7 @@
{
nextInterceptor.rename( opContext );
- LdapDN newDn = ( LdapDN ) opContext.getDn().clone();
- newDn.remove( opContext.getDn().size() - 1 );
- newDn.add( opContext.getNewRdn() );
- newDn.normalize( atRegistry.getNormalizerMapping() );
+ LdapDN newDn = opContext.getNewDn();
// add operational attributes after call in case the operation fails
ServerEntry serverEntry = new DefaultServerEntry( registries, newDn );
@@ -270,7 +266,7 @@
List<Modification> items = ModifyOperationContext.createModItems( serverEntry, ModificationOperation.REPLACE_ATTRIBUTE );
ModifyOperationContext newModify = new ModifyOperationContext( opContext.getSession(), newDn, items );
- newModify.setEntry( opContext.getEntry() );
+ newModify.setEntry( opContext.getAlteredEntry() );
service.getPartitionNexus().modify( newModify );
}
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/referral/ReferralInterceptor.java Thu Sep 24 06:38:22 2009
@@ -21,6 +21,10 @@
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.SearchControls;
+
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.core.ReferralManager;
import org.apache.directory.server.core.ReferralManagerImpl;
@@ -48,10 +52,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.directory.SearchControls;
-
/**
* An service which is responsible referral handling behavoirs. It manages
@@ -359,13 +359,6 @@
public void rename( NextInterceptor next, RenameOperationContext opContext ) throws Exception
{
- LdapDN oldName = opContext.getDn();
-
- LdapDN newName = ( LdapDN ) oldName.clone();
- newName.remove( oldName.size() - 1 );
-
- newName.add( opContext.getNewRdn() );
-
// Check if the entry is a referral itself
boolean isReferral = isReferral( opContext.getEntry() );
@@ -374,14 +367,14 @@
if ( isReferral )
{
// Update the referralManager
- LookupOperationContext lookupContext = new LookupOperationContext( opContext.getSession(), newName );
+ LookupOperationContext lookupContext = new LookupOperationContext( opContext.getSession(), opContext.getNewDn() );
ServerEntry newEntry = nexus.lookup( lookupContext );
referralManager.lockWrite();
referralManager.addReferral( newEntry );
- referralManager.removeReferral( opContext.getEntry() );
+ referralManager.removeReferral( opContext.getEntry().getOriginalEntry() );
referralManager.unlock();
}
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Thu Sep 24 06:38:22 2009
@@ -1105,21 +1105,21 @@
public void rename( NextInterceptor next, RenameOperationContext opContext ) throws Exception
{
- LdapDN name = opContext.getDn();
+ LdapDN oldDn = opContext.getDn();
Rdn newRdn = opContext.getNewRdn();
boolean deleteOldRn = opContext.getDelOldDn();
- ServerEntry entry = (ServerEntry)opContext.getEntry().getClonedEntry();
+ ServerEntry entry = (ServerEntry)opContext.getEntry().getClonedEntry();
/*
* Note: This is only a consistency checks, to the ensure that all
* mandatory attributes are available after deleting the old RDN.
- * The real modification is done in the JdbmStore class.
+ * The real modification is done in the XdbmStore class.
* - TODO: this check is missing in the moveAndRename() method
*/
if ( deleteOldRn )
{
ServerEntry tmpEntry = ( ServerEntry ) entry.clone();
- Rdn oldRDN = name.getRdn();
+ Rdn oldRDN = oldDn.getRdn();
// Delete the old RDN means we remove some attributes and values.
// We must make sure that after this operation all must attributes
@@ -1127,26 +1127,23 @@
for ( AttributeTypeAndValue atav : oldRDN )
{
AttributeType type = atRegistry.lookup( atav.getUpType() );
- String value = ( String ) atav.getNormValue().getString();
- tmpEntry.remove( type, value );
+ tmpEntry.remove( type, atav.getUpValue() );
}
+
for ( AttributeTypeAndValue atav : newRdn )
{
AttributeType type = atRegistry.lookup( atav.getUpType() );
- String value = ( String ) atav.getNormValue().getString();
- if ( !tmpEntry.contains( type, value ) )
+
+ if ( !tmpEntry.contains( type, atav.getNormValue() ) )
{
- tmpEntry.add( new DefaultServerAttribute( type, value ) );
+ tmpEntry.add( new DefaultServerAttribute( type, atav.getUpValue() ) );
}
}
// Substitute the RDN and check if the new entry is correct
- LdapDN newDn = ( LdapDN ) name.clone();
- newDn.remove( name.size() - 1 );
- newDn.add( newRdn );
+ tmpEntry.setDn( opContext.getNewDn() );
- tmpEntry.setDn( newDn );
- check( name, tmpEntry );
+ check( oldDn, tmpEntry );
// Check that no operational attributes are removed
for ( AttributeTypeAndValue atav : oldRDN )
@@ -1291,6 +1288,7 @@
throw new LdapNoSuchAttributeException( msg );
}
}
+
// If the current attribute is empty, we have to remove
// it from the entry
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/subtree/SubentryInterceptor.java Thu Sep 24 06:38:22 2009
@@ -756,6 +756,7 @@
if ( objectClasses.contains( SchemaConstants.SUBENTRY_OC ) )
{
+ // @Todo To be reviewed !!!
Subentry subentry = subentryCache.getSubentry( name.toNormName() );
SubtreeSpecification ss = subentry.getSubtreeSpecification();
LdapDN apName = ( LdapDN ) name.clone();
@@ -807,10 +808,8 @@
// calculate the new DN now for use below to modify subentry operational
// attributes contained within this regular entry with name changes
- LdapDN newName = ( LdapDN ) name.clone();
- newName.remove( newName.size() - 1 );
- newName.add( opContext.getNewRdn() );
- newName.normalize( atRegistry.getNormalizerMapping() );
+ LdapDN newName = opContext.getNewDn();
+
List<Modification> mods = getModsOnEntryRdnChange( name, newName, entry );
if ( mods.size() > 0 )
Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/trigger/TriggerInterceptor.java Thu Sep 24 06:38:22 2009
@@ -367,8 +367,9 @@
}
// Gather supplementary data.
- ClonedServerEntry renamedEntry = renameContext.getEntry();
+ ServerEntry renamedEntry = (ServerEntry)renameContext.getEntry().getClonedEntry();
+ // @TODO : To be completely reviewed !!!
LdapDN oldRDN = new LdapDN( name.getRdn().getUpName() );
LdapDN oldSuperiorDN = ( LdapDN ) name.clone();
oldSuperiorDN.remove( oldSuperiorDN.size() - 1 );
Modified: directory/apacheds/branches/apacheds-schema/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=818377&r1=818376&r2=818377&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java (original)
+++ directory/apacheds/branches/apacheds-schema/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java Thu Sep 24 06:38:22 2009
@@ -343,7 +343,10 @@
wrappedPartition.move( moveContext );
- entryMoved( oldDn, id, true );
+ // Get the modified entry
+ ClonedServerEntry modifiedEntry = lookup( id );
+
+ entryMoved( oldDn, modifiedEntry, id, true );
}
@@ -358,7 +361,11 @@
wrappedPartition.moveAndRename( moveAndRenameContext );
- entryMoved( oldDn, id, moveAndRenameContext.getDelOldDn() );
+ // Get the modified entry and store it in the context for post usage
+ ClonedServerEntry modifiedEntry = lookup( id );
+ moveAndRenameContext.setAlteredEntry( modifiedEntry );
+
+ entryMoved( oldDn, modifiedEntry, id, moveAndRenameContext.getDelOldDn() );
}
@@ -371,9 +378,16 @@
LdapDN oldDn = renameContext.getDn();
Long id = getEntryId( oldDn.getNormName() );
+ // Create the new entry
wrappedPartition.rename( renameContext );
-
- entryMoved( oldDn, id, renameContext.getDelOldDn() );
+
+ // Get the modified entry and store it in the context for post usage
+ ClonedServerEntry modifiedEntry = lookup( id );
+ renameContext.setAlteredEntry( modifiedEntry );
+
+ // Now move the potential children for the old entry
+ // and remove the old entry
+ entryMoved( oldDn, modifiedEntry, id, renameContext.getDelOldDn() );
}
@@ -387,20 +401,20 @@
* @param deleteOldEntry a flag to tell whether to delete the old entry files
* @throws Exception
*/
- private void entryMoved( LdapDN oldEntryDn, Long entryId, boolean deleteOldEntry ) throws Exception
+ private void entryMoved( LdapDN oldEntryDn, Entry modifiedEntry, Long entryIdOld, boolean deleteOldEntry ) throws Exception
{
// First, add the new entry
- add( lookup( entryId ) );
+ add( modifiedEntry );
// Then, if there are some children, move then to the new place
- IndexCursor<Long, ServerEntry> cursor = getSubLevelIndex().forwardCursor( entryId );
+ IndexCursor<Long, ServerEntry> cursor = getSubLevelIndex().forwardCursor( entryIdOld );
while ( cursor.next() )
{
IndexEntry<Long, ServerEntry> entry = cursor.get();
// except the parent entry add the rest of entries
- if( entry.getId() != entryId )
+ if( entry.getId() != entryIdOld )
{
add( wrappedPartition.lookup( entry.getId() ) );
}
@@ -415,7 +429,7 @@
boolean deleted = deleteFile( file );
LOG.warn( "move operation: deleted file {} {}", file.getAbsoluteFile(), deleted );
- // and the associated directory
+ // and the associated directory ( the file's name's minus ".ldif")
String dirName = file.getAbsolutePath();
dirName = dirName.substring( 0, dirName.indexOf( CONF_FILE_EXTN ) );
deleted = deleteFile( new File( dirName ) );
@@ -688,16 +702,24 @@
}
+ /**
+ * Recursively delete an entry and all of its children. If the entry is a directory,
+ * then get into it, call the same method on each of the contained files,
+ * and delete the directory.
+ */
private boolean deleteFile( File file )
{
if ( file.isDirectory() )
{
File[] files = file.listFiles();
+
+ // Process the contained files
for ( File f : files )
{
deleteFile( f );
}
+ // then delete the directory itself
return file.delete();
}
else