directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1085177 - in /directory: apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/ shared/trunk/ldap/model/src/main/antlr/ shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/...
Date Thu, 24 Mar 2011 22:55:04 GMT
Author: elecharny
Date: Thu Mar 24 22:55:03 2011
New Revision: 1085177

URL: http://svn.apache.org/viewvc?rev=1085177&view=rev
Log:
Last Dn cleanup :
o Added the remaining Javadoc
o Removed the normalized flag
o Removed commented code
o Some other minor refactoring

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/MoveAndRenameOperationContext.java
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/MoveOperationContext.java
    directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/DnBuilderWidget.java
    directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryDnWizardPage.java
    directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesRunnable.java
    directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java
    directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Entry.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/MoveAndRenameOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/MoveAndRenameOperationContext.java?rev=1085177&r1=1085176&r2=1085177&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/MoveAndRenameOperationContext.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/MoveAndRenameOperationContext.java
Thu Mar 24 22:55:03 2011
@@ -61,7 +61,15 @@ public class MoveAndRenameOperationConte
     {
         super( session, oldDn, newRdn, delOldRdn );
         this.newSuperiorDn = newSuperiorDn;
-        newDn = newSuperiorDn.add( newRdn );
+        
+        try
+        {
+            newDn = newSuperiorDn.add( newRdn );
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            throw new IllegalArgumentException( lide.getMessage() );
+        }
     }
 
 

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/MoveOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/MoveOperationContext.java?rev=1085177&r1=1085176&r2=1085177&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/MoveOperationContext.java
(original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/interceptor/context/MoveOperationContext.java
Thu Mar 24 22:55:03 2011
@@ -22,9 +22,10 @@ package org.apache.directory.server.core
 
 import org.apache.directory.server.core.CoreSession;
 import org.apache.directory.server.i18n.I18n;
-import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.message.MessageTypeEnum;
 import org.apache.directory.shared.ldap.model.message.ModifyDnRequest;
+import org.apache.directory.shared.ldap.model.message.controls.ManageDsaIT;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.name.Rdn;
 
@@ -67,8 +68,16 @@ public class MoveOperationContext extend
         super( session, oldDn );
         this.newSuperior = newSuperior;
         oldSuperior = oldDn.getParent();
-        rdn = (Rdn)(oldDn.getRdn().clone());
-        newDn = newSuperior.add( rdn );
+        rdn = (Rdn)( oldDn.getRdn().clone() );
+        
+        try
+        {
+            newDn = newSuperior.add( rdn );
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            throw new IllegalArgumentException( lide.getMessage() );
+        }
     }
 
     
@@ -100,7 +109,15 @@ public class MoveOperationContext extend
 
         oldSuperior = modifyDnRequest.getName().getParent();
         rdn = (Rdn)(modifyDnRequest.getName().getRdn().clone());
-        newDn = newSuperior.add( rdn );
+        
+        try
+        { 
+            newDn = newSuperior.add( rdn );
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            throw new IllegalArgumentException( lide.getMessage() );
+        }
     }
 
 

Modified: directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g?rev=1085177&r1=1085176&r2=1085177&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g (original)
+++ directory/shared/trunk/ldap/model/src/main/antlr/distinguishedName.g Thu Mar 24 22:55:03
2011
@@ -179,10 +179,34 @@ distinguishedName [Dn dn]
     }
     :
     (
-        rdn = relativeDistinguishedName[new Rdn()] { dn.add( rdn ); rdn=null; }
+        rdn = relativeDistinguishedName[new Rdn()] 
+        { 
+            try
+            { 
+                dn.add( rdn ); 
+            }
+            catch ( LdapInvalidDnException lide )
+            {
+                // Do nothing, can't get an exception here
+            } 
+                
+            rdn=null; 
+        }
         (
             ( COMMA | SEMI )
-            rdn = relativeDistinguishedName[new Rdn()] { dn.add( rdn ); rdn=null; }
+            rdn = relativeDistinguishedName[new Rdn()] 
+            { 
+                try
+                { 
+                    dn.add( rdn ); 
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    // Do nothing, can't get an exception here
+                } 
+
+                rdn=null;
+            }
         )*
         EOF
     )?
@@ -217,10 +241,16 @@ relativeDistinguishedNames [List<Rdn> rd
     }
     :
     (
-        rdn = relativeDistinguishedName[new Rdn()] { rdns.add( rdn ); }
+        rdn = relativeDistinguishedName[new Rdn()] 
+        { 
+            rdns.add( rdn );
+        }
         (
             ( COMMA | SEMI )
-            rdn = relativeDistinguishedName[new Rdn()] { rdns.add( rdn ); }
+            rdn = relativeDistinguishedName[new Rdn()] 
+            { 
+                rdns.add( rdn ); 
+            }
         )*
         EOF
     )?

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java?rev=1085177&r1=1085176&r2=1085177&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
Thu Mar 24 22:55:03 2011
@@ -83,9 +83,6 @@ public class Dn implements Iterable<Rdn>
     /** Value returned by the compareTo method if values are equals */
     public static final int EQUAL = 0;
 
-    /** A flag used to tell if the Dn has been normalized */
-    private boolean normalized;
-
     /**
      *  The RDNs that are elements of the Dn<br/>
      * NOTE THAT THESE ARE IN THE OPPOSITE ORDER FROM THAT IMPLIED BY THE JAVADOC!<br/>
@@ -118,9 +115,6 @@ public class Dn implements Iterable<Rdn>
     /** the schema manager */
     private SchemaManager schemaManager;
     
-    /** The computed hashcode */
-    private volatile int h;
-
     /**
      * An iterator over RDNs
      */
@@ -182,8 +176,6 @@ public class Dn implements Iterable<Rdn>
         this.schemaManager = schemaManager;
         upName = "";
         normName = "";
-        normalized = true;
-        hashCode();
     }
 
 
@@ -289,8 +281,6 @@ public class Dn implements Iterable<Rdn>
         parseInternal( upName, rdns );
 
         applySchemaManager( schemaManager );
-        
-        hashCode();
     }
 
 
@@ -307,9 +297,6 @@ public class Dn implements Iterable<Rdn>
     /* No protection */ Dn( SchemaManager schemaManager, String upName, String normName,
Rdn... rdns )
     {
         this.schemaManager = schemaManager;
-        
-        normalized = ( schemaManager != null ) || ( normName != null );
-        
         this.upName = upName;
         this.normName = normName;
         bytes = Strings.getBytesUtf8( upName );
@@ -337,8 +324,6 @@ public class Dn implements Iterable<Rdn>
 
         applySchemaManager( null );
         toUpName();
-        normalized = false;
-        hashCode();
     }
 
 
@@ -365,7 +350,6 @@ public class Dn implements Iterable<Rdn>
 
         applySchemaManager( dn.schemaManager );
         toUpName();
-        hashCode();
     }
 
 
@@ -390,7 +374,6 @@ public class Dn implements Iterable<Rdn>
         
         applySchemaManager( schemaManager );
         toUpName();
-        hashCode();
     }
 
 
@@ -414,7 +397,6 @@ public class Dn implements Iterable<Rdn>
         }
 
         applySchemaManager( schemaManager );
-        hashCode();
     }
 
 
@@ -464,66 +446,10 @@ public class Dn implements Iterable<Rdn>
 
         return upName;
     }
-
-
-    /**
-     * Return the User Provided prefix representation of the Dn starting at the
-     * posn position.<br/>
-     * <br/>
-     * If posn = 0, return an empty string.<br/>
-     * <br/>
-     * for Dn : sn=smith, dc=apache, dc=org
-     * <ul>
-     * <li>getUpname(0) -> ""</li>
-     * <li>getUpName(1) -> "dc=org"</li>
-     * <li>getUpname(3) -> "sn=smith, dc=apache, dc=org"</li>
-     * <li>getUpName(4) -> ArrayOutOfBoundException</li>
-     * </ul>
-     *<br/>
-     * Warning ! The returned String is not exactly the
-     * user provided Dn, as spaces before and after each RDNs have been trimmed.
-     *
-     * @param posn The starting position
-     * @return The truncated Dn
-     *
-    private String getUpNamePrefix( int posn )
-    {
-        if ( posn == 0 )
-        {
-            return "";
-        }
-
-        if ( posn > rdns.size() )
-        {
-            String message = I18n.err( I18n.ERR_04203, posn, rdns.size() );
-            LOG.error( message );
-            throw new ArrayIndexOutOfBoundsException( message );
-        }
-
-        int start = rdns.size() - posn;
-        StringBuffer sb = new StringBuffer();
-        boolean isFirst = true;
-
-        for ( int i = start; i < rdns.size(); i++ )
-        {
-            if ( isFirst )
-            {
-                isFirst = false;
-            }
-            else
-            {
-                sb.append( ',' );
-            }
-
-            sb.append( rdns.get( i ).getName() );
-        }
-
-        return sb.toString();
-    }
-
-
+    
+    
     /**
-     * Gets the hash code of this name.
+     * Gets the hash code of this Dn.
      *
      * @see java.lang.Object#hashCode()
      * @return the instance hash code
@@ -1027,24 +953,17 @@ public class Dn implements Iterable<Rdn>
      * @param newRdn the Rdn to add
      * @return the updated cloned Dn
      */
-    public Dn add( Rdn newRdn )
+    public Dn add( Rdn newRdn )  throws LdapInvalidDnException
     {
-        Dn clonedDn = copy();
-
-        clonedDn.rdns.add( 0, newRdn.clone() );
-        clonedDn.normalized = false;
-
-        // FIXME this try-catch block shouldn't be here
-        // instead this method should throw the LdapInvalidDnException
-        try
+        if ( ( newRdn == null ) || ( newRdn.size() == 0 ) )
         {
-            clonedDn.applySchemaManager( schemaManager );
-        }
-        catch ( LdapInvalidDnException e )
-        {
-            LOG.error( e.getMessage(), e );
+            return this;
         }
+        
+        Dn clonedDn = copy();
 
+        clonedDn.rdns.add( 0, newRdn.clone() );
+        clonedDn.applySchemaManager( schemaManager );
         clonedDn.toUpName();
 
         return clonedDn;
@@ -1053,7 +972,8 @@ public class Dn implements Iterable<Rdn>
 
     /**
      * Gets the parent Dn of this Dn. Null if this Dn doesn't have a parent, i.e. because
it
-     * is the empty Dn.
+     * is the empty Dn.<br/>
+     * The Parent is the right part of the Dn, when the Rdn has been removed.
      *
      * @return the parent Dn of this Dn
      */
@@ -1095,13 +1015,11 @@ public class Dn implements Iterable<Rdn>
 
 
     /**
-     * {@inheritDoc}
+     * Create a copy of the current Dn
      */
-    //@Override
     private Dn copy()
     {
         Dn dn = new Dn( schemaManager );
-        dn.normalized = normalized;
         dn.rdns = new ArrayList<Rdn>();
 
         for ( Rdn rdn : rdns )
@@ -1151,9 +1069,13 @@ public class Dn implements Iterable<Rdn>
     }
 
 
-    private static Ava atavOidToName( Ava atav, Map<String, OidNormalizer> oidsMap
)
+    /**
+     * Normalize the Ava
+     */
+    private static Ava atavOidToName( Ava atav, SchemaManager schemaManager )
         throws LdapInvalidDnException
     {
+        Map<String, OidNormalizer> oidsMap = schemaManager.getNormalizerMapping();
         String type = Strings.trim( atav.getNormType() );
 
         if ( ( type.startsWith( "oid." ) ) || ( type.startsWith( "OID." ) ) )
@@ -1218,7 +1140,7 @@ public class Dn implements Iterable<Rdn>
      * normalizing the value accordingly to its type.
      *
      * @param rdn The Rdn to modify.
-     * @param oidsMap The map of all existing oids and normalizer.
+     * @param SchemaManager The schema manager
      * @throws LdapInvalidDnException If the Rdn is invalid.
      */
     /** No qualifier */
@@ -1231,20 +1153,18 @@ public class Dn implements Iterable<Rdn>
 
         for ( Ava val : rdnCopy )
         {
-            Ava newAtav = atavOidToName( val, schemaManager.getNormalizerMapping() );
+            Ava newAtav = atavOidToName( val, schemaManager );
             rdn.addAVA( schemaManager, newAtav );
         }
     }
 
 
     /**
-     * normalizes the Dn @see {@link #normalize(Map)} however
-     * if the schema manager of the Dn is null then sets the given schema manager
-     * as the Dn's schema manager.
-     *
-     * If both, the given schema manager and that of the Dn are null then the
-     * {@link #normalizeInternal()} will be called.
+     * Normalizes the Dn using the given the schema manager
      *
+     * @param schemaManager The schemaManager to use to normalize the Dn
+     * @return The normalized Dn
+     * @throws LdapInvalidDnException If the Dn is invalid.
      */
     public Dn applySchemaManager( SchemaManager schemaManager ) throws LdapInvalidDnException
     {
@@ -1256,14 +1176,13 @@ public class Dn implements Iterable<Rdn>
             {
                 if ( size() == 0 )
                 {
-                    normalized = true;
                     bytes = null;
                     normName = "";
                     
                     return this;
                 }
 
-                StringBuffer sb = new StringBuffer();
+                StringBuilder sb = new StringBuilder();
                 boolean isFirst = true;
 
                 for ( Rdn rdn : rdns )
@@ -1290,8 +1209,6 @@ public class Dn implements Iterable<Rdn>
                     normName = newNormName;
                 }
 
-                normalized = true;
-
                 return this;
             }
         }
@@ -1330,15 +1247,15 @@ public class Dn implements Iterable<Rdn>
                 }
             }
         }
-
+        
         return this;
     }
 
 
     /**
-     * Tells if the Dn has already been normalized or not
+     * Tells if the Dn is schema aware
      *
-     * @return <code>true</code> if the Dn is already normalized.
+     * @return <code>true</code> if the Dn is schema aware.
      */
     public boolean isSchemaAware()
     {
@@ -1357,7 +1274,6 @@ public class Dn implements Iterable<Rdn>
      *     System.out.println( rdn.toString() );
      * }
      * </pre>
-     * <br/>
      * will produce this output : <br/>
      * <pre>
      * dc=org
@@ -1375,7 +1291,7 @@ public class Dn implements Iterable<Rdn>
     /**
      * Check if a DistinguishedName is null or empty.
      *
-     * @param dn The Dn to validate
+     * @param dn The Dn to check
      * @return <code>true></code> if the Dn is null or empty, <code>false</code>
      * otherwise
      */
@@ -1434,6 +1350,9 @@ public class Dn implements Iterable<Rdn>
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void readExternal( ObjectInput in ) throws IOException, ClassNotFoundException
     {
         // Read the UPName
@@ -1464,6 +1383,9 @@ public class Dn implements Iterable<Rdn>
     }
     
     
+    /**
+     * {@inheritDoc}
+     */
     public void writeExternal( ObjectOutput out ) throws IOException
     {
         if ( upName == null )
@@ -1486,8 +1408,6 @@ public class Dn implements Iterable<Rdn>
             out.writeUTF( normName );
         }
 
-        // Should we store the byte[] ???
-
         // Write the RDNs.
         // First the number of RDNs
         out.writeInt( size() );

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/DnBuilderWidget.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/DnBuilderWidget.java?rev=1085177&r1=1085176&r2=1085177&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/DnBuilderWidget.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/widgets/DnBuilderWidget.java
Thu Mar 24 22:55:03 2011
@@ -25,6 +25,7 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
 
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.name.Ava;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.name.Rdn;
@@ -303,6 +304,7 @@ public class DnBuilderWidget extends Bro
     public void validate()
     {
         Exception rdnE = null;
+        
         if ( showRDN )
         {
             try
@@ -310,6 +312,7 @@ public class DnBuilderWidget extends Bro
                 // calculate Rdn
                 String[] rdnTypes = new String[rdnLineList.size()];
                 String[] rdnValues = new String[rdnLineList.size()];
+                
                 for ( int i = 0; i < rdnLineList.size(); i++ )
                 {
                     RdnLine rdnLine = ( RdnLine ) rdnLineList.get( i );
@@ -325,6 +328,7 @@ public class DnBuilderWidget extends Bro
                         rdnLine.rdnDeleteButton.setEnabled( false );
                     }
                 }
+                
                 rdn = DnUtils.composeRdn( rdnTypes, rdnValues );
             }
             catch ( Exception e )
@@ -335,6 +339,7 @@ public class DnBuilderWidget extends Bro
         }
 
         Exception parentE = null;
+        
         if ( showParent )
         {
             try
@@ -350,10 +355,12 @@ public class DnBuilderWidget extends Bro
         }
 
         String s = ""; //$NON-NLS-1$
+        
         if ( rdnE != null )
         {
             s += rdnE.getMessage() != null ? rdnE.getMessage() : Messages.getString( "DnBuilderWidget.ErrorInRDN"
); //$NON-NLS-1$
         }
+        
         if ( parentE != null )
         {
             s += ", " + parentE.getMessage() != null ? parentE.getMessage() : Messages.getString(
"DnBuilderWidget.ErrorInParentDN" ); //$NON-NLS-1$ //$NON-NLS-2$
@@ -370,7 +377,15 @@ public class DnBuilderWidget extends Bro
                 Dn dn;
                 if ( showParent && showRDN )
                 {
-                    dn = parentDn.add( rdn );
+                    try
+                    {
+                        dn = parentDn.add( rdn );
+                    }
+                    catch ( LdapInvalidDnException lide )
+                    {
+                        // Do nothing
+                        dn = Dn.EMPTY_DN;
+                    }
                 }
                 else if ( showParent )
                 {
@@ -378,13 +393,21 @@ public class DnBuilderWidget extends Bro
                 }
                 else if ( showRDN )
                 {
-                    dn = new Dn();
-                    dn.add( rdn );
+                    try
+                    {
+                        dn = new Dn( rdn );
+                    }
+                    catch ( LdapInvalidDnException lide )
+                    {
+                        // Do nothing
+                        dn = Dn.EMPTY_DN;
+                    }
                 }
                 else
                 {
-                    dn = new Dn();
+                    dn = Dn.EMPTY_DN;
                 }
+                
                 previewText.setText( dn.getName() );
             }
         }

Modified: directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryDnWizardPage.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryDnWizardPage.java?rev=1085177&r1=1085176&r2=1085177&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryDnWizardPage.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.common/src/main/java/org/apache/directory/studio/ldapbrowser/common/wizards/NewEntryDnWizardPage.java
Thu Mar 24 22:55:03 2011
@@ -241,6 +241,7 @@ public class NewEntryDnWizardPage extend
 
             // set new Dn
             Dn dn;
+            
             if ( wizard.isNewContextEntry() )
             {
                 try
@@ -254,7 +255,15 @@ public class NewEntryDnWizardPage extend
             }
             else
             {
-                dn = dnBuilderWidget.getParentDn().add( dnBuilderWidget.getRdn() );
+                try
+                {
+                    dn = dnBuilderWidget.getParentDn().add( dnBuilderWidget.getRdn() );
+                }
+                catch ( LdapInvalidDnException lide )
+                {
+                    // Do nothing
+                    dn = Dn.EMPTY_DN;
+                }
             }
             newEntry.setDn( dn );
 
@@ -338,45 +347,57 @@ public class NewEntryDnWizardPage extend
 
             Rdn rdn = dnBuilderWidget.getRdn();
             Dn parentDn = dnBuilderWidget.getParentDn();
-            final Dn dn = parentDn.add(  rdn );
-
-            // check if parent exists
-            ReadEntryRunnable readEntryRunnable1 = new ReadEntryRunnable( wizard.getSelectedConnection(),
parentDn );
-            RunnableContextRunner.execute( readEntryRunnable1, getContainer(), false );
-            IEntry parentEntry = readEntryRunnable1.getReadEntry();
-            if ( parentEntry == null )
+            
+            try
             {
-                getShell().getDisplay().syncExec( new Runnable()
+                final Dn dn = parentDn.add( rdn );
+
+                // check if parent exists
+                ReadEntryRunnable readEntryRunnable1 = new ReadEntryRunnable( wizard.getSelectedConnection(),
parentDn );
+                RunnableContextRunner.execute( readEntryRunnable1, getContainer(), false
);
+                IEntry parentEntry = readEntryRunnable1.getReadEntry();
+                
+                if ( parentEntry == null )
                 {
-                    public void run()
+                    getShell().getDisplay().syncExec( new Runnable()
                     {
-                        MessageDialog
-                            .openError( getShell(),
-                                Messages.getString( "NewEntryDnWizardPage.Error" ), //$NON-NLS-1$
-                                NLS
-                                    .bind(
-                                        Messages.getString( "NewEntryDnWizardPage.ParentDoesNotExist"
), dnBuilderWidget.getParentDn().toString() ) ); //$NON-NLS-1$
-                    }
-                } );
-                return null;
-            }
+                        public void run()
+                        {
+                            MessageDialog
+                                .openError( getShell(),
+                                    Messages.getString( "NewEntryDnWizardPage.Error" ), //$NON-NLS-1$
+                                    NLS
+                                        .bind(
+                                            Messages.getString( "NewEntryDnWizardPage.ParentDoesNotExist"
), dnBuilderWidget.getParentDn().toString() ) ); //$NON-NLS-1$
+                        }
+                    } );
+                    
+                    return null;
+                }
 
-            // check that new entry does not exists yet 
-            ReadEntryRunnable readEntryRunnable2 = new ReadEntryRunnable( wizard.getSelectedConnection(),
dn );
-            RunnableContextRunner.execute( readEntryRunnable2, getContainer(), false );
-            IEntry entry = readEntryRunnable2.getReadEntry();
-            if ( entry != null )
-            {
-                getShell().getDisplay().syncExec( new Runnable()
+                // check that new entry does not exists yet 
+                ReadEntryRunnable readEntryRunnable2 = new ReadEntryRunnable( wizard.getSelectedConnection(),
dn );
+                RunnableContextRunner.execute( readEntryRunnable2, getContainer(), false
);
+                IEntry entry = readEntryRunnable2.getReadEntry();
+                
+                if ( entry != null )
                 {
-                    public void run()
+                    getShell().getDisplay().syncExec( new Runnable()
                     {
-                        MessageDialog
-                            .openError(
-                                getShell(),
-                                Messages.getString( "NewEntryDnWizardPage.Error" ), NLS.bind(
Messages.getString( "NewEntryDnWizardPage.EntryAlreadyExists" ), dn.toString() ) ); //$NON-NLS-1$
//$NON-NLS-2$
-                    }
-                } );
+                        public void run()
+                        {
+                            MessageDialog
+                                .openError(
+                                    getShell(),
+                                    Messages.getString( "NewEntryDnWizardPage.Error" ), NLS.bind(
Messages.getString( "NewEntryDnWizardPage.EntryAlreadyExists" ), dn.toString() ) ); //$NON-NLS-1$
//$NON-NLS-2$
+                        }
+                    } );
+                    
+                    return null;
+                }
+            }
+            catch ( LdapInvalidDnException lide )
+            {
                 return null;
             }
         }

Modified: directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesRunnable.java?rev=1085177&r1=1085176&r2=1085177&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesRunnable.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/MoveEntriesRunnable.java
Thu Mar 24 22:55:03 2011
@@ -30,6 +30,7 @@ import java.util.Set;
 import javax.naming.ContextNotEmptyException;
 import javax.naming.directory.SearchControls;
 
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
 import org.apache.directory.studio.connection.core.Connection;
@@ -161,7 +162,17 @@ public class MoveEntriesRunnable impleme
 
             IEntry oldEntry = oldEntries[i];
             Dn oldDn = oldEntry.getDn();
-            Dn newDn = parentDn.add( oldDn.getRdn() );
+            
+            Dn newDn = null;
+            
+            try
+            {
+                newDn = parentDn.add( oldDn.getRdn() );
+            }
+            catch ( LdapInvalidDnException lide )
+            {
+                newDn = Dn.EMPTY_DN;
+            }
 
             // try to move entry
             RenameEntryRunnable.renameEntry( browserConnection, oldEntry, newDn, dummyMonitor
);

Modified: directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java?rev=1085177&r1=1085176&r2=1085177&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/jobs/RenameEntryRunnable.java
Thu Mar 24 22:55:03 2011
@@ -31,6 +31,7 @@ import javax.naming.directory.SearchCont
 import javax.naming.ldap.Control;
 import javax.naming.ldap.ManageReferralControl;
 
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.name.Rdn;
 import org.apache.directory.studio.common.core.jobs.StudioProgressMonitor;
@@ -146,7 +147,16 @@ public class RenameEntryRunnable impleme
 
         Dn oldDn = oldEntry.getDn();
         Dn parentDn = oldDn.getParent();
-        Dn newDn = parentDn.add( newRdn );
+        Dn newDn = null;
+        
+        try
+        {
+            newDn = parentDn.add( newRdn );
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            newDn = Dn.EMPTY_DN;
+        }
 
         // use a dummy monitor to be able to handle exceptions
         StudioProgressMonitor dummyMonitor = new StudioProgressMonitor( monitor );

Modified: directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Entry.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Entry.java?rev=1085177&r1=1085176&r2=1085177&view=diff
==============================================================================
--- directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Entry.java
(original)
+++ directory/studio/trunk/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/Entry.java
Thu Mar 24 22:55:03 2011
@@ -21,6 +21,7 @@
 package org.apache.directory.studio.ldapbrowser.core.model.impl;
 
 
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.name.Rdn;
 import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
@@ -81,8 +82,16 @@ public class Entry extends AbstractEntry
      */
     public Dn getDn()
     {
-        Dn dn = parent.getDn().add( rdn );
-        return dn;
+        try
+        {
+            Dn dn = parent.getDn().add( rdn );
+            
+            return dn;
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            return null;
+        }
     }
 
 



Mime
View raw message