directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1005740 - /directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java
Date Fri, 08 Oct 2010 09:18:50 GMT
Author: pamarcelot
Date: Fri Oct  8 09:18:48 2010
New Revision: 1005740

URL: http://svn.apache.org/viewvc?rev=1005740&view=rev
Log:
Fixed NPEs.

Modified:
    directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java

Modified: directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java?rev=1005740&r1=1005739&r2=1005740&view=diff
==============================================================================
--- directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java
(original)
+++ directory/shared/trunk/dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/LdapResultDsml.java
Fri Oct  8 09:18:48 2010
@@ -21,12 +21,14 @@
 package org.apache.directory.shared.dsmlv2.reponse;
 
 
+import java.util.Collection;
 import java.util.List;
 
 import org.apache.directory.shared.dsmlv2.DsmlDecorator;
 import org.apache.directory.shared.dsmlv2.ParserUtils;
 import org.apache.directory.shared.ldap.message.LdapResult;
 import org.apache.directory.shared.ldap.message.Message;
+import org.apache.directory.shared.ldap.message.Referral;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.util.LdapURL;
@@ -76,11 +78,11 @@ public class LdapResultDsml implements D
         }
 
         // Matched DN
-        String matchedDN = result.getMatchedDn().getName();
+        DN matchedDN = result.getMatchedDn();
 
-        if ( !matchedDN.equals( "" ) )
+        if ( ( matchedDN != null ) && ( !matchedDN.getName().equals( "" ) ) )
         {
-            root.addAttribute( "matchedDN", matchedDN );
+            root.addAttribute( "matchedDN", matchedDN.getName() );
         }
 
         // Controls
@@ -99,15 +101,18 @@ public class LdapResultDsml implements D
             errorMessageElement.addText( errorMessage );
         }
 
-        // Referals
-        List<String> referals = ( List<String> ) result.getReferral().getLdapUrls();
-
-        if ( referals != null )
+        // Referrals
+        Referral referral = result.getReferral();
+        if ( referral != null )
         {
-            for ( String url : referals )
+            Collection<String> ldapUrls = referral.getLdapUrls();
+            if ( ldapUrls != null )
             {
-                Element referalElement = root.addElement( "referal" );
-                referalElement.addText( url );
+                for ( String ldapUrl : ldapUrls )
+                {
+                    Element referalElement = root.addElement( "referal" );
+                    referalElement.addText( ldapUrl );
+                }
             }
         }
 



Mime
View raw message