You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2012/02/03 17:00:46 UTC

svn commit: r1240225 - in /directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse: Dsmlv2ResponseGrammar.java SearchResponse.java SearchResponseDsml.java

Author: pamarcelot
Date: Fri Feb  3 16:00:45 2012
New Revision: 1240225

URL: http://svn.apache.org/viewvc?rev=1240225&view=rev
Log:
Fix for a NPE raised in Studio when exporting entries to DSML, DIRSTUDIO-765 (Can not export DSML).

Modified:
    directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java
    directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResponse.java
    directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResponseDsml.java

Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java?rev=1240225&r1=1240224&r2=1240225&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java Fri Feb  3 16:00:45 2012
@@ -1621,11 +1621,11 @@ public final class Dsmlv2ResponseGrammar
             if ( attributeValue != null )
             {
                 searchResponse = new SearchResponse(
-                    ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ), null );
+                    ParserUtils.parseAndVerifyRequestID( attributeValue, xpp ) );
             }
             else
             {
-                searchResponse = new SearchResponse( -1, null );
+                searchResponse = new SearchResponse();
             }
 
             container.getBatchResponse().addResponse( new SearchResponseDsml(

Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResponse.java?rev=1240225&r1=1240224&r2=1240225&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResponse.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResponse.java Fri Feb  3 16:00:45 2012
@@ -46,13 +46,21 @@ public class SearchResponse extends Abst
 
     /**
      * Creates a new instance of SearchResponse.
+     */
+    public SearchResponse()
+    {
+        super( -1, null );
+    }
+
+
+    /**
+     * Creates a new instance of SearchResponse.
      *
      * @param messageId the response eliciting this Request
-     * @param type the message type of the response
      */
-    public SearchResponse( int messageId, MessageTypeEnum type )
+    public SearchResponse( int messageId )
     {
-        super( messageId, type );
+        super( messageId, null );
     }
 
 
@@ -71,6 +79,20 @@ public class SearchResponse extends Abst
 
 
     /**
+     * Removes a Search Result Entry
+     *
+     * @param searchResultEntry
+     *      the Search Result Entry to remove
+     * @return
+     *      true (as per the general contract of the Collection.remove method)
+     */
+    public boolean removeSearchResultEntry( SearchResultEntryDsml searchResultEntry )
+    {
+        return searchResultEntryList.remove( searchResultEntry );
+    }
+
+
+    /**
      * Gets the Current Search Result Entry
      * 
      * @return
@@ -116,6 +138,20 @@ public class SearchResponse extends Abst
 
 
     /**
+     * Removes a Search Result Reference
+     *
+     * @param searchResultReference
+     *      the Search Result Reference to remove
+     * @return
+     *      true (as per the general contract of the Collection.remove method)
+     */
+    public boolean removeSearchResultReference( SearchResultReferenceDsml searchResultReference )
+    {
+        return searchResultReferenceList.remove( searchResultReference );
+    }
+
+
+    /**
      * Gets the current Search Result Reference
      *
      * @return

Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResponseDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResponseDsml.java?rev=1240225&r1=1240224&r2=1240225&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResponseDsml.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResponseDsml.java Fri Feb  3 16:00:45 2012
@@ -55,7 +55,7 @@ public class SearchResponseDsml extends 
      */
     public SearchResponseDsml( LdapApiService codec )
     {
-        super( codec, null );
+        super( codec, new SearchResponse() );
     }
 
 
@@ -112,8 +112,30 @@ public class SearchResponseDsml extends 
      * @return
      *      true if this list contained the specified element.
      */
-    public boolean removeResponse( DsmlDecorator<Response> response )
+    public boolean removeResponse( DsmlDecorator<? extends Response> response )
     {
+        if ( response instanceof SearchResultEntry )
+        {
+            ( ( SearchResponse ) getDecorated() ).removeSearchResultEntry(
+                ( SearchResultEntryDsml ) response );
+        }
+        else if ( response instanceof SearchResultReference )
+        {
+            ( ( SearchResponse ) getDecorated() ).removeSearchResultReference(
+                ( SearchResultReferenceDsml ) response );
+        }
+        else if ( response instanceof SearchResultDone )
+        {
+            if ( response.equals( ( ( SearchResponse ) getDecorated() ).getSearchResultDone() ) )
+            {
+                ( ( SearchResponse ) getDecorated() ).setSearchResultDone( null );
+            }
+        }
+        else
+        {
+            throw new IllegalArgumentException( "Unidentified search resp type" );
+        }
+
         return responses.remove( response );
     }