directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r400111 - in /directory/trunks/shared/ldap/src: main/antlr/ main/java/org/apache/directory/shared/ldap/trigger/ test/java/org/apache/directory/shared/ldap/trigger/
Date Fri, 05 May 2006 16:55:48 GMT
Author: ersiner
Date: Fri May  5 09:55:46 2006
New Revision: 400111

URL: http://svn.apache.org/viewcvs?rev=400111&view=rev
Log:
changes:
* Removed ConditionalParserFailureBasedOnCallerFeedback (what a name!) implementation from
the Trigger Specification parser because we're caching the populated beans.
* Modified some toString() overrides in order to make TriggerSpecification bean return actually
specification based string representation. (The toString() outcome can be parsed in order
to create actually the same bean.)

Removed:
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/ConditionalParserFailureBasedOnCallerFeedback.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/GenericLdapOperationTokenListener.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/LdapOperationTokenListener.java
Modified:
    directory/trunks/shared/ldap/src/main/antlr/TriggerSpecification.g
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/SearchScope.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureSearchContextOption.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecification.java
    directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParser.java
    directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java

Modified: directory/trunks/shared/ldap/src/main/antlr/TriggerSpecification.g
URL: http://svn.apache.org/viewcvs/directory/trunks/shared/ldap/src/main/antlr/TriggerSpecification.g?rev=400111&r1=400110&r2=400111&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/antlr/TriggerSpecification.g (original)
+++ directory/trunks/shared/ldap/src/main/antlr/TriggerSpecification.g Fri May  5 09:55:46
2006
@@ -72,8 +72,6 @@
     private boolean isNormalizing = false;
     private NameComponentNormalizer normalizer;
     
-    private LdapOperationTokenListener caller = null;
-    
     private ActionTime triggerActionTime;
     
     private LdapOperation triggerLdapOperation;
@@ -84,6 +82,7 @@
     
     private List triggerStoredProcedureParameters;
     
+    
     /**
      * Creates a (normalizing) subordinate DnParser for parsing Names.
      * This method MUST be called for each instance while we cannot do
@@ -114,11 +113,7 @@
             throw new NullPointerException( "dnParser is null: " + msg );
         }
     }
-    
-	public void registerLdapOperationTokenListener( LdapOperationTokenListener listener )
-	{
-		this.caller = listener;
-	}
+
 
     /**
      * Sets the NameComponentNormalizer for this parser's dnParser.
@@ -200,14 +195,7 @@
     log.debug( "entered bindOperationAndStoredProcedureCall()" );
 }
     :
-    ID_bind
-    {
-    	if ( caller.ldapOperationTokenRead( LdapOperation.BIND ) == false )
-    	{
-    		throw new ConditionalParserFailureBasedOnCallerFeedback( LdapOperation.BIND  );
-    	}
-    }
-    theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_bind theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( bindStoredProcedureParameterList )?
     CLOSE_PARAN
@@ -218,14 +206,7 @@
     log.debug( "entered unbindOperationAndStoredProcedureCall()" );
 }
     :
-    ID_unbind
-    {
-    	if ( caller.ldapOperationTokenRead( LdapOperation.UNBIND ) == false )
-    	{
-    		throw new ConditionalParserFailureBasedOnCallerFeedback( LdapOperation.UNBIND );
-    	}
-    }
-    theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_unbind theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( unbindStoredProcedureParameterList )?
     CLOSE_PARAN
@@ -236,14 +217,7 @@
     log.debug( "entered searchOperationAndStoredProcedureCall()" );
 }
     :
-    ID_search
-    {
-    	if ( caller.ldapOperationTokenRead( LdapOperation.SEARCH ) == false )
-    	{
-    		throw new ConditionalParserFailureBasedOnCallerFeedback( LdapOperation.SEARCH );
-    	}
-    }
-    theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_search theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( searchStoredProcedureParameterList )?
     CLOSE_PARAN
@@ -254,14 +228,7 @@
     log.debug( "entered modifyOperationAndStoredProcedureCall()" );
 }
     :
-    ID_modify
-    {
-    	if ( caller.ldapOperationTokenRead( LdapOperation.MODIFY ) == false )
-    	{
-    		throw new ConditionalParserFailureBasedOnCallerFeedback( LdapOperation.MODIFY );
-    	}
-    }
-    theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_modify theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( modifyStoredProcedureParameterList )?
     CLOSE_PARAN
@@ -272,14 +239,7 @@
     log.debug( "entered addOperationAndStoredProcedureCall()" );
 }
     :
-    ID_add
-    {
-    	if ( caller.ldapOperationTokenRead( LdapOperation.ADD ) == false )
-    	{
-    		throw new ConditionalParserFailureBasedOnCallerFeedback( LdapOperation.ADD );
-    	}
-    }
-    theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_add theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( addStoredProcedureParameterList )?
     CLOSE_PARAN
@@ -290,14 +250,7 @@
     log.debug( "entered deleteOperationAndStoredProcedureCall()" );
 }
     :
-    ID_delete
-    {
-    	if ( caller.ldapOperationTokenRead( LdapOperation.DELETE ) == false )
-    	{
-    		throw new ConditionalParserFailureBasedOnCallerFeedback( LdapOperation.DELETE );
-    	}
-    }
-    theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_delete theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( deleteStoredProcedureParameterList )?
     CLOSE_PARAN
@@ -308,14 +261,7 @@
     log.debug( "entered modDNOperationAndStoredProcedureCall()" );
 }
     :
-    ID_modDN
-    {
-    	if ( caller.ldapOperationTokenRead( LdapOperation.MODDN ) == false )
-    	{
-    		throw new ConditionalParserFailureBasedOnCallerFeedback( LdapOperation.MODDN );
-    	}
-    }
-    theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_modDN theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( modDNStoredProcedureParameterList )?
     CLOSE_PARAN
@@ -326,14 +272,7 @@
     log.debug( "entered compareOperationAndStoredProcedureCall()" );
 }
     :
-    ID_compare
-    {
-    	if ( caller.ldapOperationTokenRead( LdapOperation.COMPARE ) == false )
-    	{
-    		throw new ConditionalParserFailureBasedOnCallerFeedback( LdapOperation.COMPARE );
-    	}
-    }
-    theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_compare theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( compareStoredProcedureParameterList )?
     CLOSE_PARAN
@@ -344,14 +283,7 @@
     log.debug( "entered abandonOperationAndStoredProcedureCall()" );
 }
     :
-    ID_abandon
-    {
-    	if ( caller.ldapOperationTokenRead( LdapOperation.ABANDON ) == false )
-    	{
-    		throw new ConditionalParserFailureBasedOnCallerFeedback( LdapOperation.ABANDON );
-    	}
-    }
-    theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_abandon theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( abandonStoredProcedureParameterList )?
     CLOSE_PARAN
@@ -362,14 +294,7 @@
     log.debug( "entered extendedOperationAndStoredProcedureCall()" );
 }
     :
-    ID_extended
-    {
-    	if ( caller.ldapOperationTokenRead( LdapOperation.EXTENDED ) == false )
-    	{
-    		throw new ConditionalParserFailureBasedOnCallerFeedback( LdapOperation.EXTENDED );
-    	}
-    }
-    theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_extended theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( extendedStoredProcedureParameterList )?
     CLOSE_PARAN
@@ -637,7 +562,7 @@
     Name spSearchContext = null;
 }
     :
-    ID_searchContext ( SP )+
+    ID_searchContext ( SP )+ // FIXME: SP should not be mandatory if an OPEN_CURLY follows
         ( OPEN_CURLY ( SP )*
             ( ID_search_scope ( SP )+ searchScope=storedProcedureSearchScope ( SP )* )?
         CLOSE_CURLY ( SP )+ )?

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/SearchScope.java
URL: http://svn.apache.org/viewcvs/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/SearchScope.java?rev=400111&r1=400110&r2=400111&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/SearchScope.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/SearchScope.java
Fri May  5 09:55:46 2006
@@ -52,7 +52,7 @@
      */
     public String toString()
     {
-        return "scope" + "\"" + name + "\"";
+        return name;
     }
     
 

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureSearchContextOption.java
URL: http://svn.apache.org/viewcvs/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureSearchContextOption.java?rev=400111&r1=400110&r2=400111&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureSearchContextOption.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/StoredProcedureSearchContextOption.java
Fri May  5 09:55:46 2006
@@ -56,7 +56,7 @@
 
     public String toString()
     {
-        return baseObject.toString();
+        return "searchContext { scope " + searchScope + " } \"" + baseObject + "\""; 
     }
 
     /* (non-Javadoc)

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecification.java
URL: http://svn.apache.org/viewcvs/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecification.java?rev=400111&r1=400110&r2=400111&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecification.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecification.java
Fri May  5 09:55:46 2006
@@ -17,8 +17,11 @@
 
 package org.apache.directory.shared.ldap.trigger;
 
+import java.util.Iterator;
 import java.util.List;
 
+import org.apache.commons.lang.NullArgumentException;
+
 /**
  * The Trigger Specification Bean.
  * 
@@ -41,6 +44,14 @@
     public TriggerSpecification( LdapOperation ldapOperation, ActionTime actionTime, String
storedProcedureName, List storedProcedureOptions, List storedProcedureParameters )
     {
         super();
+        if ( ldapOperation == null || 
+            actionTime == null || 
+            storedProcedureName == null || 
+            storedProcedureOptions == null || 
+            storedProcedureParameters == null )
+        {
+            throw new NullArgumentException( "TriggerSpecification cannot be initialized
with any NULL argument." );
+        }
         this.ldapOperation = ldapOperation;
         this.actionTime = actionTime;
         this.storedProcedureName = storedProcedureName;
@@ -79,10 +90,43 @@
      */
     public String toString()
     {
-        return actionTime + " " + 
-            ldapOperation +
-            " CALL \"" + storedProcedureName + "\" { " +
-            storedProcedureOptions + " } ( " + storedProcedureParameters + " )";
+        StringBuffer buffer = new StringBuffer();
+        buffer.append( actionTime );
+        buffer.append( " " );
+        buffer.append( ldapOperation );
+        buffer.append( " CALL \"" );
+        buffer.append( storedProcedureName );
+        buffer.append( "\" { " );
+        if ( storedProcedureOptions.size() > 0 )
+        {
+            Iterator it = storedProcedureOptions.iterator();
+            while ( it.hasNext() )
+            {
+                StoredProcedureOption spOption = ( StoredProcedureOption ) it.next();
+                buffer.append( spOption );
+                if ( it.hasNext() )
+                {
+                    buffer.append( ", " );
+                }
+            }
+        }
+        buffer.append( " } ( " );
+        if ( storedProcedureParameters.size() > 0 )
+        {
+            Iterator it = storedProcedureParameters.iterator();
+            while ( it.hasNext() )
+            {
+                StoredProcedureParameter spParameter = ( StoredProcedureParameter ) it.next();
+                buffer.append( spParameter );
+                if ( it.hasNext() )
+                {
+                    buffer.append( ", " );
+                }
+            }
+        }
+        buffer.append( " )" );
+        
+        return buffer.toString();
     }
 
     /* (non-Javadoc)

Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParser.java
URL: http://svn.apache.org/viewcvs/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParser.java?rev=400111&r1=400110&r2=400111&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParser.java
(original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParser.java
Fri May  5 09:55:46 2006
@@ -49,7 +49,7 @@
     /**
      * Creates a TriggerSpecification parser.
      */
-    public TriggerSpecificationParser( LdapOperationTokenListener listener )
+    public TriggerSpecificationParser()
     {
         this.lexer = new ReusableAntlrTriggerSpecificationLexer( new StringReader( "" ) );
         this.parser = new ReusableAntlrTriggerSpecificationParser( lexer );
@@ -57,22 +57,13 @@
         this.parser.init(); // this method MUST be called while we cannot do
         // constructor overloading for antlr generated parser
         this.isNormalizing = false;
-        this.registerLdapOperationTokenListener( listener );
-    }
-    
-    /**
-     * Creates a TriggerSpecification parser.
-     */
-    public TriggerSpecificationParser()
-    {
-        this( GenericLdapOperationTokenListener.AnyOperationListener );
     }
 
 
     /**
      * Creates a normalizing TriggerSpecification parser.
      */
-    public TriggerSpecificationParser( LdapOperationTokenListener listener, NameComponentNormalizer
normalizer )
+    public TriggerSpecificationParser( NameComponentNormalizer normalizer )
     {
         this.lexer = new ReusableAntlrTriggerSpecificationLexer( new StringReader( "" ) );
         this.parser = new ReusableAntlrTriggerSpecificationParser( lexer );
@@ -81,15 +72,6 @@
         this.parser.init(); // this method MUST be called while we cannot do
         // constructor overloading for ANTLR generated parser
         this.isNormalizing = true;
-        this.registerLdapOperationTokenListener( listener );
-    }
-    
-    /**
-     * Creates a normalizing TriggerSpecification parser.
-     */
-    public TriggerSpecificationParser( NameComponentNormalizer normalizer )
-    {
-        this( GenericLdapOperationTokenListener.AnyOperationListener, normalizer );
     }
 
 
@@ -117,7 +99,7 @@
      * @throws ParseException
      *          if there are any recognition errors (bad syntax)
      */
-    public synchronized TriggerSpecification parse( String spec ) throws ParseException,
ConditionalParserFailureBasedOnCallerFeedback
+    public synchronized TriggerSpecification parse( String spec ) throws ParseException
     {
         TriggerSpecification triggerSpecification = null;
 
@@ -147,11 +129,6 @@
         
         return triggerSpecification;
 
-    }
-    
-    public void registerLdapOperationTokenListener( LdapOperationTokenListener listener )
-    {
-        parser.registerLdapOperationTokenListener( listener );
     }
 
 

Modified: directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java
URL: http://svn.apache.org/viewcvs/directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java?rev=400111&r1=400110&r2=400111&view=diff
==============================================================================
--- directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java
(original)
+++ directory/trunks/shared/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java
Fri May  5 09:55:46 2006
@@ -56,9 +56,7 @@
     }
 
     public void testWithOperationParameters() throws Exception
-    {
-        parser.registerLdapOperationTokenListener( GenericLdapOperationTokenListener.DeleteListener
);
-        
+    {        
         TriggerSpecification triggerSpecification = null;
         
         String spec = "BEFORE delete CALL \"BackupUtilities.backupDeletedEntry\" ($name,
$deletedEntry)";
@@ -78,9 +76,7 @@
     }
     
     public void testWithGenericParameters() throws Exception
-    {
-        parser.registerLdapOperationTokenListener( GenericLdapOperationTokenListener.AddListener
);
-        
+    {        
         TriggerSpecification triggerSpecification = null;
         
         String spec = "AFTER add CALL \"Logger.logAddOperation\" ($entry, $attributes, $operationPrincipal)";
@@ -102,9 +98,7 @@
     }
     
     public void testWithLanguageOptionAndComments() throws Exception
-    {
-        parser.registerLdapOperationTokenListener( GenericLdapOperationTokenListener.SearchListener
);
-        
+    {        
         TriggerSpecification triggerSpecification = null;
         
         String spec = "INSTEADOF search # do not do search \n" +
@@ -123,9 +117,7 @@
     }
     
     public void testWithSearchContextOption() throws Exception
-    {
-        parser.registerLdapOperationTokenListener( GenericLdapOperationTokenListener.BindListener
);
-        
+    {        
         TriggerSpecification triggerSpecification = null;
         
         String spec = "BEFORE bind  # Action Time and Operation \n" +
@@ -146,30 +138,6 @@
         assertEquals( triggerSpecification.getStoredProcedureParameters().size(), 1 );
         assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
             StoredProcedureParameter.BindStoredProcedureParameter.NAME ) );
-    }
-    
-    public void  testLdapOperationTokenListener() throws Exception
-    {
-        LdapOperationTokenListener expectedOperationToken = GenericLdapOperationTokenListener.CompareListener;
-        parser.registerLdapOperationTokenListener( expectedOperationToken );
-        
-        TriggerSpecification triggerSpecification = null;
-        
-        String longUnexpectedSpec = "INSTEADOF search \n" +
-            "CALL \"Search.customSearchSP\" \n" +
-                "{ searchContext { scope one } \"cn=Stored Procedures, ou=system\" } \n"
+
-                    "($baseObject, $scope, $derefAliases, $sizeLimit, $timeLimit, $timeLimit,
$filter, $attributes, $operationPrincipal)";
-
-        try
-        {
-            triggerSpecification = parser.parse( longUnexpectedSpec );
-            fail( "Unintended execution of this line." );
-        }
-        catch ( ConditionalParserFailureBasedOnCallerFeedback e )
-        {
-            assertEquals( e.getReadToken(), LdapOperation.SEARCH );
-            assertNull( triggerSpecification );
-        }
     }
     
 }



Mime
View raw message