directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r519364 - in /directory: apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/ apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/ shared/trunk/ldap/src/main/antlr/ shared/trunk/ldap/src/ma...
Date Sat, 17 Mar 2007 16:21:39 GMT
Author: ersiner
Date: Sat Mar 17 09:21:38 2007
New Revision: 519364

URL: http://svn.apache.org/viewvc?view=rev&rev=519364
Log:
* Changed TriggerSpecification Grammar to allow multiple SP Calls per Trigger Execution.
* The grammar is now less flexible about spaces, but we'll fix it.
* Changed the TriggerService to execute all SP Call Specs per Trigger Execution in the order
they are given.
* Reflected changes to the appropriate tests.

Modified:
    directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/BackupUtilities.java
    directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceITest.java
    directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/SubentryServiceForTriggersITest.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerService.java
    directory/shared/trunk/ldap/src/main/antlr/TriggerSpecification.g
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecification.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java

Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/BackupUtilities.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/BackupUtilities.java?view=diff&rev=519364&r1=519363&r2=519364
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/BackupUtilities.java
(original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/BackupUtilities.java
Sat Mar 17 09:21:38 2007
@@ -22,4 +22,11 @@
         backupCtx.createSubcontext( deletedEntryRdn, deletedEntry );
         log.info( "Backed up deleted entry to \"" + ( ( LdapContext ) backupCtx.lookup( deletedEntryRdn
) ).getNameInNamespace() + "\"" );
     }
+    
+    public static void duplicateDeletedEntry( LdapContext ctx, Name deletedEntryName, Name
operationPrincipal, Attributes deletedEntry ) throws NamingException
+    {
+        LdapContext backupCtx = ( LdapContext ) ctx.lookup( "ou=backupContext,ou=system"
);
+        String deletedEntryRdn = deletedEntryName.get( deletedEntryName.size() - 1 );
+        backupCtx.createSubcontext( deletedEntryRdn + "," + deletedEntryRdn, deletedEntry
);
+    }
 }

Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceITest.java?view=diff&rev=519364&r1=519363&r2=519364
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceITest.java
(original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/DefaulTriggerServiceITest.java
Sat Mar 17 09:21:38 2007
@@ -54,7 +54,9 @@
         
         // Create the Triger Specification within a Trigger Subentry.
         createTriggerSubentry( "triggerSubentry1",
-            "AFTER Delete CALL \"" + BackupUtilities.class.getName() + ".backupDeleted\"
( $ldapContext \"\", $name, $operationPrincipal, $deletedEntry )" );
+            "AFTER Delete " +
+            "CALL \"" + BackupUtilities.class.getName() + ".backupDeleted\" ( $ldapContext
\"\", $name, $operationPrincipal, $deletedEntry ); " +
+            "CALL \"" + BackupUtilities.class.getName() + ".duplicateDeletedEntry\" ( $ldapContext
\"\", $name, $operationPrincipal, $deletedEntry );" );
         
         // Create a test entry which is selected by the Trigger Subentry.
         Attributes testEntry = new AttributesImpl( "ou", "testou", true );
@@ -73,6 +75,7 @@
         
         // Check if the Trigger really worked (backed up the deleted entry).
         assertNotNull( sysRoot.lookup( "ou=testou,ou=backupContext" ) );
+        assertNotNull( sysRoot.lookup( "ou=testou,ou=testou,ou=backupContext" ) );
     }
     
     /*public void testBeforeDeleteLogWarning() throws NamingException

Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/SubentryServiceForTriggersITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/SubentryServiceForTriggersITest.java?view=diff&rev=519364&r1=519363&r2=519364
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/SubentryServiceForTriggersITest.java
(original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/trigger/SubentryServiceForTriggersITest.java
Sat Mar 17 09:21:38 2007
@@ -71,7 +71,7 @@
         objectClass.add( "triggerExecutionSubentry" );
         subentry.put( objectClass );
         subentry.put( "subtreeSpecification", "{ base \"ou=configuration\" }" );
-        subentry.put( "prescriptiveTriggerSpecification", "AFTER Delete CALL \"LogUtils.logDelete\"($name)"
);
+        subentry.put( "prescriptiveTriggerSpecification", "AFTER Delete CALL \"LogUtils.logDelete\"($name);"
);
         subentry.put( "cn", "testsubentry" );
         return subentry;
     }
@@ -86,7 +86,7 @@
         subentry.put( objectClass );
         String spec = "{ base \"ou=configuration\", specificExclusions { chopBefore:\"cn=unmarked\"
} }";
         subentry.put( "subtreeSpecification", spec );
-        subentry.put( "prescriptiveTriggerSpecification", "AFTER Delete CALL \"LogUtils.logDelete\"($name)"
);
+        subentry.put( "prescriptiveTriggerSpecification", "AFTER Delete CALL \"LogUtils.logDelete\"($name);"
);
         subentry.put( "cn", "testsubentry" );
         return subentry;
     }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerService.java?view=diff&rev=519364&r1=519363&r2=519364
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerService.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/trigger/TriggerService.java
Sat Mar 17 09:21:38 2007
@@ -57,6 +57,7 @@
 import org.apache.directory.shared.ldap.trigger.LdapOperation;
 import org.apache.directory.shared.ldap.trigger.TriggerSpecification;
 import org.apache.directory.shared.ldap.trigger.TriggerSpecificationParser;
+import org.apache.directory.shared.ldap.trigger.TriggerSpecification.SPSpec;
 import org.apache.directory.shared.ldap.util.DirectoryClassUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -583,22 +584,27 @@
 
     private Object executeTrigger( TriggerSpecification tsec, StoredProcedureParameterInjector
injector, ServerLdapContext callerRootCtx ) throws NamingException
     {
-        List arguments = new ArrayList();
-        arguments.addAll( injector.getArgumentsToInject( tsec.getStoredProcedureParameters()
) );
-        List typeList = new ArrayList();
-        typeList.addAll( getTypesFromValues( arguments ) );
+    	List returnValues = new ArrayList();
+    	List<SPSpec> spSpecs = tsec.getSPSpecs();
+        for (SPSpec spSpec : spSpecs) {
+        	List arguments = new ArrayList();
+        	arguments.addAll( injector.getArgumentsToInject( spSpec.getParameters() ) );
+        	List<Class> typeList = new ArrayList<Class>();
+            typeList.addAll( getTypesFromValues( arguments ) );
+            Class[] types = getTypesFromValues( arguments ).toArray( EMPTY_CLASS_ARRAY );
+            Object[] values = arguments.toArray();
+            Object returnValue = executeProcedure( callerRootCtx, spSpec.getName(), types,
values );
+            returnValues.add(returnValue);
+		}
         
-        Class[] types = ( Class[] ) ( getTypesFromValues( arguments ).toArray( EMPTY_CLASS_ARRAY
) );
-        Object[] values = arguments.toArray();
-        
-        return executeProcedure( callerRootCtx, tsec.getStoredProcedureName(), types, values
);
+        return returnValues; 
     }
     
     private static Class[] EMPTY_CLASS_ARRAY = new Class[ 0 ];
     
-    private List getTypesFromValues( List objects )
+    private List<Class> getTypesFromValues( List objects )
     {
-        List types = new ArrayList();
+        List<Class> types = new ArrayList<Class>();
         
         Iterator it = objects.iterator();
         

Modified: directory/shared/trunk/ldap/src/main/antlr/TriggerSpecification.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/TriggerSpecification.g?view=diff&rev=519364&r1=519363&r2=519364
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/TriggerSpecification.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/TriggerSpecification.g Sat Mar 17 09:21:38
2007
@@ -29,6 +29,7 @@
 
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.NormalizerMappingResolver;
+import org.apache.directory.shared.ldap.trigger.TriggerSpecification.SPSpec;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -78,10 +79,11 @@
     
     private String triggerStoredProcedureName;
     
-    private List triggerStoredProcedureOptions;
-    
-    private List triggerStoredProcedureParameters;
+	private List triggerStoredProcedureParameters;
+	
+	private List triggerStoredProcedureOptions;
     
+    private List<SPSpec> spSpecs;   
     
     public void init()
     {
@@ -107,8 +109,7 @@
 {
     log.debug( "entered wrapperEntryPoint()" );
     triggerSpec = null;
-    triggerStoredProcedureOptions = new ArrayList();
-    triggerStoredProcedureParameters = new ArrayList();
+    spSpecs = new ArrayList<SPSpec>(); 
 }
     :
     ( SP )* triggerSpec=triggerSpecification ( SP )* EOF
@@ -124,16 +125,15 @@
     triggerSpec = null;
 }
     :
-    actionTime ( SP )+ ldapOperationAndStoredProcedureCall
+    actionTime ( SP )+ ldapOperationAndStoredProcedureCalls
     { triggerSpec = new TriggerSpecification( triggerLdapOperation,
                                               triggerActionTime,
-                                              triggerStoredProcedureName,
-                                              triggerStoredProcedureOptions,
-                                              triggerStoredProcedureParameters
+                                              spSpecs
                                             );
     }
     ;
-    
+
+// Currently we only support "AFTER" Triggers   
 actionTime
 {
     log.debug( "entered actionTime()" );
@@ -141,75 +141,93 @@
     : ID_AFTER { triggerActionTime = ActionTime.AFTER; }
     ;
     
-ldapOperationAndStoredProcedureCall
+ldapOperationAndStoredProcedureCalls
 {
     log.debug( "entered ldapOperationAndStoredProcedureCall()" );
 }
-    : modifyOperationAndStoredProcedureCall { triggerLdapOperation = LdapOperation.MODIFY;
}
-    | addOperationAndStoredProcedureCall { triggerLdapOperation = LdapOperation.ADD; }
-    | deleteOperationAndStoredProcedureCall { triggerLdapOperation = LdapOperation.DELETE;
}
-    | modifyDNOperationAndStoredProcedureCall
+    : modifyOperationAndStoredProcedureCalls { triggerLdapOperation = LdapOperation.MODIFY;
}
+    | addOperationAndStoredProcedureCalls { triggerLdapOperation = LdapOperation.ADD; }
+    | deleteOperationAndStoredProcedureCalls { triggerLdapOperation = LdapOperation.DELETE;
}
+    | modifyDNOperationAndStoredProcedureCalls // Will decide operation type for this one
later
     ;
 
 // -----------------------------------------------------------------------------
-//  XXXOperationAndStoredProcedureCall
+//  XXXOperationAndStoredProcedureCalls
 // -----------------------------------------------------------------------------
 
-modifyOperationAndStoredProcedureCall
+modifyOperationAndStoredProcedureCalls
 {
-    log.debug( "entered modifyOperationAndStoredProcedureCall()" );
+    log.debug( "entered modifyOperationAndStoredProcedureCalls()" );
 }
     :
-    ID_modify theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_modify
+    ( theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( modifyStoredProcedureParameterList )?
-    CLOSE_PARAN
+    CLOSE_PARAN ( SP )* SEMI
+    {
+    	spSpecs.add( new SPSpec(triggerStoredProcedureName, triggerStoredProcedureOptions, triggerStoredProcedureParameters
) );
+    })+
     ;
 
-addOperationAndStoredProcedureCall
+addOperationAndStoredProcedureCalls
 {
-    log.debug( "entered addOperationAndStoredProcedureCall()" );
+    log.debug( "entered addOperationAndStoredProcedureCalls()" );
 }
     :
-    ID_add theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_add
+    ( theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( addStoredProcedureParameterList )?
-    CLOSE_PARAN
+    CLOSE_PARAN ( SP )* SEMI
+    {
+    	spSpecs.add( new SPSpec(triggerStoredProcedureName, triggerStoredProcedureOptions, triggerStoredProcedureParameters
) );
+    }
+    )+
     ;
 
-deleteOperationAndStoredProcedureCall
+deleteOperationAndStoredProcedureCalls
 {
-    log.debug( "entered deleteOperationAndStoredProcedureCall()" );
+    log.debug( "entered deleteOperationAndStoredProcedureCalls()" );
 }
     :
-    ID_delete theCompositeRuleForCallAndSPNameAndSPOptionList
+    ID_delete
+    ( theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( deleteStoredProcedureParameterList )?
-    CLOSE_PARAN
+    CLOSE_PARAN ( SP )* SEMI
+    {
+    	spSpecs.add( new SPSpec(triggerStoredProcedureName, triggerStoredProcedureOptions, triggerStoredProcedureParameters
) );
+    }
+    )+
     ;
 
-modifyDNOperationAndStoredProcedureCall
+modifyDNOperationAndStoredProcedureCalls
 {
-    log.debug( "entered modifyDNOperationAndStoredProcedureCall()" );
+    log.debug( "entered modifyDNOperationAndStoredProcedureCalls()" );
 }
     :
     ID_modifyDN DOT
-    ( ID_modifyDNRename { triggerLdapOperation = LdapOperation.MODIFYDN_RENAME; }
+    ( ( ID_modifyDNRename { triggerLdapOperation = LdapOperation.MODIFYDN_RENAME; }
     | ID_modifyDNExport { triggerLdapOperation = LdapOperation.MODIFYDN_EXPORT; }
     | ID_modifyDNImport { triggerLdapOperation = LdapOperation.MODIFYDN_IMPORT; } )
     theCompositeRuleForCallAndSPNameAndSPOptionList
     OPEN_PARAN ( SP )*
         ( modifyDNStoredProcedureParameterList )?
-    CLOSE_PARAN
+    CLOSE_PARAN ( SP )* SEMI
+    {
+    	spSpecs.add( new SPSpec(triggerStoredProcedureName, triggerStoredProcedureOptions, triggerStoredProcedureParameters
) );
+    }
+    )+
     ;
 
 // -----------------------------------------------------------------------------
 // The following rule does not make any sense semantically. Just placed for
 // reducing repetition. All OperationAndStoredProcedureCall type are heavily
 // context sensitive where their StoredProcedureParameterList depends on their
-// Operation type. Other elements that sit between these two dependend elements
+// Operation type. Other elements that sit between these two dependent elements
 // are repeated for all OperationAndStoredProcedureCall type rules. So the
-// the fallowing rule is for the part falling between those two dependend parts.
+// the following rule is for the part falling between those two dependent parts.
 // -----------------------------------------------------------------------------
 
 theCompositeRuleForCallAndSPNameAndSPOptionList
@@ -217,9 +235,15 @@
     log.debug( "entered theCompositeRuleForCallAndSPNameAndSPOptionList()" );
 }
     :
-    ( SP )+ ID_CALL ( SP )+ triggerStoredProcedureName=fullyQualifiedStoredProcedureName
( SP )*
+    SP ID_CALL
+    {
+    	triggerStoredProcedureName = null;
+    	triggerStoredProcedureParameters = new ArrayList();
+		triggerStoredProcedureOptions = new ArrayList();
+    }
+    ( SP )+ triggerStoredProcedureName=fullyQualifiedStoredProcedureName ( SP )*
         ( genericStoredProcedureOptionList ( SP )* )?
-    {  }
+    { }
     ;
 
 // -----------------------------------------------------------------------------
@@ -516,6 +540,8 @@
 OPEN_CURLY : '{' ;
 
 CLOSE_CURLY : '}' ;
+
+SEMI : ';' ;
 
 SEP : ',' ;
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecification.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecification.java?view=diff&rev=519364&r1=519363&r2=519364
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecification.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/trigger/TriggerSpecification.java
Sat Mar 17 09:21:38 2007
@@ -38,28 +38,26 @@
     
     private ActionTime actionTime;
     
-    private String storedProcedureName;
+    private List<SPSpec> spSpecs; 
     
-    private List storedProcedureOptions;
     
-    private List storedProcedureParameters;
     
-    public TriggerSpecification( LdapOperation ldapOperation, ActionTime actionTime, String
storedProcedureName, List storedProcedureOptions, List storedProcedureParameters )
+    public TriggerSpecification( LdapOperation ldapOperation, ActionTime actionTime, List<SPSpec>
spSpecs )
     {
         super();
         if ( ldapOperation == null || 
             actionTime == null || 
-            storedProcedureName == null || 
-            storedProcedureOptions == null || 
-            storedProcedureParameters == null )
+            spSpecs == null )
         {
             throw new NullArgumentException( "TriggerSpecification cannot be initialized
with any NULL argument." );
         }
+        if ( spSpecs.size() == 0 )
+        {
+        	throw new IllegalArgumentException( "TriggerSpecification cannot be initialized
with emtpy SPSPec list." );
+        }
         this.ldapOperation = ldapOperation;
         this.actionTime = actionTime;
-        this.storedProcedureName = storedProcedureName;
-        this.storedProcedureOptions = storedProcedureOptions;
-        this.storedProcedureParameters = storedProcedureParameters;
+        this.spSpecs = spSpecs;
     }
 
     public ActionTime getActionTime()
@@ -72,129 +70,83 @@
         return ldapOperation;
     }
 
-    public String getStoredProcedureName()
+    public List<SPSpec> getSPSpecs() {
+		return spSpecs;
+	}
+    
+    public static class SPSpec
     {
-        return storedProcedureName;
-    }
+    	private String name;
+        
+        private List<String> options;
+        
+        private List<String> parameters;
 
-    public List getStoredProcedureOptions()
-    {
-        return storedProcedureOptions;
-    }
+        public SPSpec(String name, List<String> options, List<String> parameters)
{
+			super();
+			this.name = name;
+			this.options = options;
+			this.parameters = parameters;
+		}
+        
+		public String getName() {
+			return name;
+		}
+
+		public List<String> getOptions() {
+			return options;
+		}
+
+		public List<String> getParameters() {
+			return parameters;
+		}
+
+		@Override
+		public int hashCode() {
+			final int PRIME = 31;
+			int result = 1;
+			result = PRIME * result + ((name == null) ? 0 : name.hashCode());
+			result = PRIME * result + ((options == null) ? 0 : options.hashCode());
+			result = PRIME * result + ((parameters == null) ? 0 : parameters.hashCode());
+			return result;
+		}
+
+		@Override
+		public boolean equals(Object obj) {
+			if (this == obj)
+				return true;
+			if (obj == null)
+				return false;
+			if (getClass() != obj.getClass())
+				return false;
+			final SPSpec other = (SPSpec) obj;
+			if (name == null) {
+				if (other.name != null)
+					return false;
+			} else if (!name.equals(other.name))
+				return false;
+			if (options == null) {
+				if (other.options != null)
+					return false;
+			} else if (!options.equals(other.options))
+				return false;
+			if (parameters == null) {
+				if (other.parameters != null)
+					return false;
+			} else if (!parameters.equals(other.parameters))
+				return false;
+			return true;
+		}
+
+		
 
-    public List getStoredProcedureParameters()
-    {
-        return storedProcedureParameters;
     }
 
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#toString()
-     */
-    public String toString()
-    {
-        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.toString() );
-                if ( it.hasNext() )
-                {
-                    buffer.append( ", " );
-                }
-            }
-        }
-        buffer.append( " )" );
-        
-        return buffer.toString();
-    }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#hashCode()
-     */
-    public int hashCode()
-    {
-        final int PRIME = 31;
-        int result = 1;
-        result = PRIME * result + ( ( actionTime == null ) ? 0 : actionTime.hashCode() );
-        result = PRIME * result + ( ( ldapOperation == null ) ? 0 : ldapOperation.hashCode()
);
-        result = PRIME * result + ( ( storedProcedureName == null ) ? 0 : storedProcedureName.hashCode()
);
-        result = PRIME * result + ( ( storedProcedureOptions == null ) ? 0 : storedProcedureOptions.hashCode()
);
-        result = PRIME * result + ( ( storedProcedureParameters == null ) ? 0 : storedProcedureParameters.hashCode()
);
-        return result;
-    }
 
-    /* (non-Javadoc)
-     * @see java.lang.Object#equals(java.lang.Object)
-     */
-    public boolean equals( Object obj )
-    {
-        if ( this == obj )
-            return true;
-        if ( obj == null )
-            return false;
-        if ( getClass() != obj.getClass() )
-            return false;
-        final TriggerSpecification other = ( TriggerSpecification ) obj;
-        if ( actionTime == null )
-        {
-            if ( other.actionTime != null )
-                return false;
-        }
-        else if ( !actionTime.equals( other.actionTime ) )
-            return false;
-        if ( ldapOperation == null )
-        {
-            if ( other.ldapOperation != null )
-                return false;
-        }
-        else if ( !ldapOperation.equals( other.ldapOperation ) )
-            return false;
-        if ( storedProcedureName == null )
-        {
-            if ( other.storedProcedureName != null )
-                return false;
-        }
-        else if ( !storedProcedureName.equals( other.storedProcedureName ) )
-            return false;
-        if ( storedProcedureOptions == null )
-        {
-            if ( other.storedProcedureOptions != null )
-                return false;
-        }
-        else if ( !storedProcedureOptions.equals( other.storedProcedureOptions ) )
-            return false;
-        if ( storedProcedureParameters == null )
-        {
-            if ( other.storedProcedureParameters != null )
-                return false;
-        }
-        else if ( !storedProcedureParameters.equals( other.storedProcedureParameters ) )
-            return false;
-        return true;
-    }
+
+	
+    
     
 }

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java?view=diff&rev=519364&r1=519363&r2=519364
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/trigger/TriggerSpecificationParserTest.java
Sat Mar 17 09:21:38 2007
@@ -21,7 +21,10 @@
 package org.apache.directory.shared.ldap.trigger;
 
 
+import java.util.List;
+
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.trigger.TriggerSpecification.SPSpec;
 
 import junit.framework.TestCase;
 
@@ -62,19 +65,23 @@
     {        
         TriggerSpecification triggerSpecification = null;
         
-        String spec = "AFTER Delete CALL \"BackupUtilities.backupDeletedEntry\" ($name, $deletedEntry)";
+        String spec = "AFTER Delete CALL \"BackupUtilities.backupDeletedEntry\" ($name, $deletedEntry);";
 
         triggerSpecification = parser.parse( spec );
         
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
-        assertEquals( triggerSpecification.getStoredProcedureName(), "BackupUtilities.backupDeletedEntry"
);
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.DELETE );
-        assertEquals( triggerSpecification.getStoredProcedureOptions().size(), 0 );
-        assertEquals( triggerSpecification.getStoredProcedureParameters().size(), 2 );
-        assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
+        List<SPSpec> spSpecs = triggerSpecification.getSPSpecs();
+        assertTrue( spSpecs != null );
+        assertTrue( spSpecs.size() == 1 );
+        SPSpec theSpec = spSpecs.get( 0 );
+        assertEquals( theSpec.getName(), "BackupUtilities.backupDeletedEntry" );
+        assertEquals( theSpec.getOptions().size(), 0 );
+        assertEquals( theSpec.getParameters().size(), 2 );
+        assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Delete_NAME.instance() ) );
-        assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
+        assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Delete_DELETED_ENTRY.instance() ) );
     }
     
@@ -82,21 +89,25 @@
     {        
         TriggerSpecification triggerSpecification = null;
         
-        String spec = "AFTER Add CALL \"Logger.logAddOperation\" ($entry, $attributes, $operationPrincipal)";
+        String spec = "AFTER Add CALL \"Logger.logAddOperation\" ($entry, $attributes, $operationPrincipal);";
 
         triggerSpecification = parser.parse( spec );
         
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
-        assertEquals( triggerSpecification.getStoredProcedureName(), "Logger.logAddOperation"
);
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.ADD );
-        assertEquals( triggerSpecification.getStoredProcedureOptions().size(), 0 );
-        assertEquals( triggerSpecification.getStoredProcedureParameters().size(), 3 );
-        assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
+        List<SPSpec> spSpecs = triggerSpecification.getSPSpecs();
+        assertTrue( spSpecs != null );
+        assertTrue( spSpecs.size() == 1 );
+        SPSpec theSpec = spSpecs.get( 0 );
+        assertEquals( theSpec.getName(), "Logger.logAddOperation" );        
+        assertEquals( theSpec.getOptions().size(), 0 );
+        assertEquals( theSpec.getParameters().size(), 3 );
+        assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Add_ENTRY.instance() ) );
-        assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
+        assertTrue(theSpec.getParameters().contains(
             StoredProcedureParameter.Add_ATTRIBUTES.instance()) );
-        assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
+        assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Generic_OPERATION_PRINCIPAL.instance() ) );
     }
     
@@ -104,18 +115,22 @@
     {        
         TriggerSpecification triggerSpecification = null;
         
-        String spec = "AFTER Modify CALL \"Logger.logModifyOperation\" {languageScheme \"Java\"}()";
+        String spec = "AFTER Modify CALL \"Logger.logModifyOperation\" {languageScheme \"Java\"}();";
 
         triggerSpecification = parser.parse( spec );
         
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
-        assertEquals( triggerSpecification.getStoredProcedureName(), "Logger.logModifyOperation"
);
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.MODIFY );
-        assertEquals( triggerSpecification.getStoredProcedureOptions().size(), 1 );
-        assertTrue( triggerSpecification.getStoredProcedureOptions().contains(
+        List<SPSpec> spSpecs = triggerSpecification.getSPSpecs();
+        assertTrue( spSpecs != null );
+        assertTrue( spSpecs.size() == 1 );
+        SPSpec theSpec = spSpecs.get( 0 );
+        assertEquals( theSpec.getName(), "Logger.logModifyOperation" );
+        assertEquals( theSpec.getOptions().size(), 1 );
+        assertTrue( theSpec.getOptions().contains(
             new StoredProcedureLanguageSchemeOption( "Java" ) ) );
-        assertEquals( triggerSpecification.getStoredProcedureParameters().size(),  0 );
+        assertEquals( theSpec.getParameters().size(),  0 );
     }
     
     public void testWithSearchContextOption() throws Exception
@@ -124,22 +139,26 @@
         
         String spec = "AFTER ModifyDN.Rename CALL \"Logger.logModifyDNRenameOperation\" \n"
+
             "{ searchContext { scope one } \"cn=Logger,ou=Stored Procedures,ou=system\" }
\n" +
-            "($entry, $newrdn)  # Stored Procedure Parameter(s)";
+            "($entry, $newrdn);  # Stored Procedure Parameter(s)";
 
         triggerSpecification = parser.parse( spec );
         
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
-        assertEquals( triggerSpecification.getStoredProcedureName(), "Logger.logModifyDNRenameOperation"
);
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.MODIFYDN_RENAME
);
-        assertEquals( triggerSpecification.getStoredProcedureOptions().size(), 1 );
-        assertTrue( triggerSpecification.getStoredProcedureOptions().contains(
+        List<SPSpec> spSpecs = triggerSpecification.getSPSpecs();
+        assertTrue( spSpecs != null );
+        assertTrue( spSpecs.size() == 1 );
+        SPSpec theSpec = spSpecs.get( 0 );
+        assertEquals( theSpec.getName(), "Logger.logModifyDNRenameOperation" );
+        assertEquals( theSpec.getOptions().size(), 1 );
+        assertTrue( theSpec.getOptions().contains(
             new StoredProcedureSearchContextOption(
                 new LdapDN( "cn=Logger,ou=Stored Procedures,ou=system" ), SearchScope.ONE
) ) );
-        assertEquals( triggerSpecification.getStoredProcedureParameters().size(), 2 );
-        assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
+        assertEquals( theSpec.getParameters().size(), 2 );
+        assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.ModifyDN_ENTRY.instance() ) );
-        assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
+        assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.ModifyDN_NEW_RDN.instance() ) );
     }
     
@@ -147,22 +166,62 @@
     {        
         TriggerSpecification triggerSpecification = null;
         
-        String spec = "AFTER Delete CALL \"BackupUtilities.backupDeletedEntry\" ($ldapContext
\"ou=Backup,ou=System\", $name, $deletedEntry)";
+        String spec = "AFTER Delete CALL \"BackupUtilities.backupDeletedEntry\" ($ldapContext
\"ou=Backup,ou=System\", $name, $deletedEntry);";
 
         triggerSpecification = parser.parse( spec );
         
         assertNotNull( triggerSpecification );
         assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
-        assertEquals( triggerSpecification.getStoredProcedureName(), "BackupUtilities.backupDeletedEntry"
);
         assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.DELETE );
-        assertEquals( triggerSpecification.getStoredProcedureOptions().size(), 0 );
-        assertEquals( triggerSpecification.getStoredProcedureParameters().size(), 3 );
-        assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
+        List<SPSpec> spSpecs = triggerSpecification.getSPSpecs();
+        assertTrue( spSpecs != null );
+        assertTrue( spSpecs.size() == 1 );
+        SPSpec theSpec = spSpecs.get( 0 );
+        assertEquals( theSpec.getName(), "BackupUtilities.backupDeletedEntry" );
+        assertEquals( theSpec.getOptions().size(), 0 );
+        assertEquals( theSpec.getParameters().size(), 3 );
+        assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Delete_NAME.instance() ) );
-        assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
+        assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Delete_DELETED_ENTRY.instance() ) );
-        assertTrue( triggerSpecification.getStoredProcedureParameters().contains(
+        assertTrue( theSpec.getParameters().contains(
             StoredProcedureParameter.Generic_LDAP_CONTEXT.instance( new LdapDN( "ou=Backup,ou=System"
) ) ) );
+    }
+    
+    public void testMultipleSPCalls() throws Exception
+    {        
+        TriggerSpecification triggerSpecification = null;
+        
+        String spec = "AFTER Delete " +
+        	"CALL \"BackupUtilities.backupDeletedEntry\" ($ldapContext \"ou=Backup,ou=System\",
$name, $deletedEntry); " +
+        	"CALL \"BackupUtilities.recreateDeletedEntry\" ($name, $deletedEntry);";
+
+        triggerSpecification = parser.parse( spec );
+        
+        assertNotNull( triggerSpecification );
+        assertEquals( triggerSpecification.getActionTime(), ActionTime.AFTER );
+        assertEquals( triggerSpecification.getLdapOperation(), LdapOperation.DELETE );
+        List<SPSpec> spSpecs = triggerSpecification.getSPSpecs();
+        assertTrue( spSpecs != null );
+        assertTrue( spSpecs.size() == 2 );
+        SPSpec firstSpec = spSpecs.get( 0 );
+        assertEquals( firstSpec.getName(), "BackupUtilities.backupDeletedEntry" );
+        assertEquals( firstSpec.getOptions().size(), 0 );
+        assertEquals( firstSpec.getParameters().size(), 3 );
+        assertTrue( firstSpec.getParameters().contains(
+            StoredProcedureParameter.Delete_NAME.instance() ) );
+        assertTrue( firstSpec.getParameters().contains(
+            StoredProcedureParameter.Delete_DELETED_ENTRY.instance() ) );
+        assertTrue( firstSpec.getParameters().contains(
+            StoredProcedureParameter.Generic_LDAP_CONTEXT.instance( new LdapDN( "ou=Backup,ou=System"
) ) ) );
+        SPSpec secondSpec = spSpecs.get( 1 );
+        assertEquals( secondSpec.getName(), "BackupUtilities.recreateDeletedEntry" );
+        assertEquals( secondSpec.getOptions().size(), 0 );
+        assertEquals( secondSpec.getParameters().size(), 2 );
+        assertTrue( secondSpec.getParameters().contains(
+            StoredProcedureParameter.Delete_NAME.instance() ) );
+        assertTrue( secondSpec.getParameters().contains(
+            StoredProcedureParameter.Delete_DELETED_ENTRY.instance() ) );
     }
     
 }



Mime
View raw message