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 2010/03/17 11:50:06 UTC

svn commit: r924219 - in /directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap: exception/LdapConfigurationException.java exception/LdapOperationException.java name/DN.java

Author: elecharny
Date: Wed Mar 17 10:50:06 2010
New Revision: 924219

URL: http://svn.apache.org/viewvc?rev=924219&view=rev
Log:
o Added two helper methods in DN to convert back and forth Name
o Added the resolvedDn field in LdapOperationException
o Added a setCause method in LdapConfigurationException

Modified:
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapConfigurationException.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapOperationException.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapConfigurationException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapConfigurationException.java?rev=924219&r1=924218&r2=924219&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapConfigurationException.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapConfigurationException.java Wed Mar 17 10:50:06 2010
@@ -74,4 +74,15 @@ public class LdapConfigurationException 
     {
         return cause;
     }
+    
+    
+    /**
+     * Set the root cause
+     *
+     * @param cause The cause
+     */
+    public void setCause( Throwable cause )
+    {
+        this.cause = cause;
+    }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapOperationException.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapOperationException.java?rev=924219&r1=924218&r2=924219&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapOperationException.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/exception/LdapOperationException.java Wed Mar 17 10:50:06 2010
@@ -21,6 +21,7 @@ package org.apache.directory.shared.ldap
 
 
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.DN;
 
 
 /**
@@ -37,6 +38,27 @@ public class LdapOperationException exte
 
     /** The operation resultCode */
     protected ResultCodeEnum resultCode;
+    
+    /** The resolved DN */
+    protected DN resolvedDn;
+
+    /**
+     * @return the resolvedDn
+     */
+    public DN getResolvedDn()
+    {
+        return resolvedDn;
+    }
+
+
+    /**
+     * @param resolvedDn the resolvedDn to set
+     */
+    public void setResolvedDn( DN resolvedDn )
+    {
+        this.resolvedDn = resolvedDn;
+    }
+
 
     /**
      * Creates a new instance of LdapOperationException.

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java?rev=924219&r1=924218&r2=924219&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java Wed Mar 17 10:50:06 2010
@@ -43,6 +43,8 @@ import org.apache.directory.shared.ldap.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.sun.jndi.ldap.LdapName;
+
 
 /**
  * The DN class contains a DN (Distinguished Name).
@@ -1642,4 +1644,50 @@ public class DN implements Externalizabl
             rdns.add( rdn );
         }
     }
+    
+    
+    /**
+     * Convert a {@link javax.naming.Name} to a DN
+     *
+     * @param name The Name to convert
+     * @return A DN
+     */
+    public static DN fromName( Name name )
+    {
+        try
+        {
+            DN dn = new DN( name.toString() );
+        
+            return dn;
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            // TODO : check if we must throw an exception.
+            // Logically, the Name must be valid.
+            return null;
+        }
+    }
+    
+    
+    /**
+     * Convert a DN to a {@link javax.naming.Name}
+     *
+     * @param name The DN to convert
+     * @return A Name
+     */
+    public static Name toName( DN dn )
+    {
+        try
+        {
+            Name name = new LdapName( dn.toString() );
+        
+            return name;
+        }
+        catch ( InvalidNameException ine )
+        {
+            // TODO : check if we must throw an exception.
+            // Logically, the DN must be valid.
+            return null;
+        }
+    }
 }