directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ersi...@apache.org
Subject svn commit: r405313 - /directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/
Date Tue, 09 May 2006 05:52:55 GMT
Author: ersiner
Date: Mon May  8 22:52:54 2006
New Revision: 405313

URL: http://svn.apache.org/viewcvs?rev=405313&view=rev
Log:
Got rid of System.out.println()s (This is the main purpose of this commit.)
Added some SP parameter injection stuff. (This may change later.)

Added:
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/AbstractStoredProcedureParameterInjector.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/AddDeleteStoredProcedureParameterInjector.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/DeleteStoredProcedureParameterInjector.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/StoredProcedureParameterInjector.java
Modified:
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/TriggerService.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/TriggerSpecCache.java

Added: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/AbstractStoredProcedureParameterInjector.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/AbstractStoredProcedureParameterInjector.java?rev=405313&view=auto
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/AbstractStoredProcedureParameterInjector.java
(added)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/AbstractStoredProcedureParameterInjector.java
Mon May  8 22:52:54 2006
@@ -0,0 +1,118 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.directory.server.core.trigger;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Name;
+import javax.naming.NameParser;
+import javax.naming.NamingException;
+
+import org.apache.directory.server.core.invocation.Invocation;
+import org.apache.directory.server.core.jndi.ServerContext;
+import org.apache.directory.shared.ldap.trigger.StoredProcedureParameter;
+
+public abstract class AbstractStoredProcedureParameterInjector implements StoredProcedureParameterInjector
+{
+    private Invocation invocation;
+    private NameParser nameParser;
+    private Map injectors;
+    
+    public AbstractStoredProcedureParameterInjector()
+    {
+        injectors = new HashMap();
+        injectors.put( StoredProcedureParameter.OPERATION_PRINCIPAL, $operationPrincipalInjector
);
+        injectors.put( StoredProcedureParameter.OPERATION_TIME, $operationTimeInjector );
+    }
+    
+    protected Name getOperationPrincipal() throws NamingException
+    {
+        Principal principal = ( ( ServerContext ) invocation.getCaller() ).getPrincipal();
+        Name userName = nameParser.parse( principal.getName() );
+        return userName;
+    }
+    
+    protected Date getOperationTime()
+    {
+        return new Date();
+    }
+    
+    protected Map getInjectors()
+    {
+        return injectors;
+    }
+    
+    public Invocation getInvocation()
+    {
+        return invocation;
+    }
+    
+    public NameParser getNameParser()
+    {
+        return nameParser;
+    }
+    
+    public void setInvocation( Invocation invocation )
+    {
+        this.invocation = invocation;
+    }
+
+    public void setNameParser( NameParser nameParser )
+    {
+        this.nameParser = nameParser;
+    }
+    
+    
+    public final List getArgumentsToInject( List parameterList )
+    {
+        List arguments = new ArrayList();
+        
+        Iterator it = parameterList.iterator();
+        while ( it.hasNext() )
+        {
+            StoredProcedureParameter spParameter = ( StoredProcedureParameter ) it.next();
+            arguments.add( injectors.get( spParameter ) );
+        }
+        
+        return arguments;
+    }
+    
+    MicroInjector $operationPrincipalInjector = new MicroInjector()
+    {
+        public Object inject() throws NamingException
+        {
+            return getOperationPrincipal();
+        };
+    };
+    
+    MicroInjector $operationTimeInjector = new MicroInjector()
+    {
+        public Object inject() throws NamingException
+        {
+            return getOperationTime();
+        };
+    };
+
+
+}

Added: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/AddDeleteStoredProcedureParameterInjector.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/AddDeleteStoredProcedureParameterInjector.java?rev=405313&view=auto
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/AddDeleteStoredProcedureParameterInjector.java
(added)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/AddDeleteStoredProcedureParameterInjector.java
Mon May  8 22:52:54 2006
@@ -0,0 +1,78 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.directory.server.core.trigger;
+
+import java.util.Map;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+
+import org.apache.directory.shared.ldap.trigger.StoredProcedureParameter.AddStoredProcedureParameter;
+
+public class AddDeleteStoredProcedureParameterInjector extends AbstractStoredProcedureParameterInjector
+{
+    private Name addedEntryName;
+    private Attributes addedEntry;
+    
+    private Map injectors;
+    
+    public AddDeleteStoredProcedureParameterInjector()
+    {        
+        injectors = super.getInjectors();
+        injectors.put( AddStoredProcedureParameter.ENTRY, $entryInjector );
+        injectors.put( AddStoredProcedureParameter.ATTRIBUTES, $attributesInjector );
+    }
+    
+    public void setAddedEntryName( Name addedEntryName )
+    {
+        this.addedEntryName = addedEntryName;
+    }
+    
+    public Name getAddedEntryName()
+    {
+        return addedEntryName;
+    }
+    
+    public Attributes getAddedEntry()
+    {
+        return addedEntry;
+    }
+
+    public void setAddedEntry( Attributes addedEntry )
+    {
+        this.addedEntry = addedEntry;
+    }
+    
+    MicroInjector $entryInjector = new MicroInjector()
+    {
+        public Object inject() throws NamingException
+        {
+            return addedEntryName;
+        };
+    };
+    
+    MicroInjector $attributesInjector = new MicroInjector()
+    {
+        public Object inject() throws NamingException
+        {
+            return addedEntry;
+        };
+    };
+
+}

Added: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/DeleteStoredProcedureParameterInjector.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/DeleteStoredProcedureParameterInjector.java?rev=405313&view=auto
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/DeleteStoredProcedureParameterInjector.java
(added)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/DeleteStoredProcedureParameterInjector.java
Mon May  8 22:52:54 2006
@@ -0,0 +1,65 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.directory.server.core.trigger;
+
+import java.util.Map;
+
+import javax.naming.Name;
+import javax.naming.NamingException;
+import javax.naming.directory.Attributes;
+
+import org.apache.directory.server.core.partition.DirectoryPartitionNexusProxy;
+import org.apache.directory.shared.ldap.trigger.StoredProcedureParameter.DeleteStoredProcedureParameter;
+
+public class DeleteStoredProcedureParameterInjector extends AbstractStoredProcedureParameterInjector
+{
+    private Name deletedEntryName;
+    
+    private Map injectors;
+    
+    public DeleteStoredProcedureParameterInjector()
+    {        
+        injectors = super.getInjectors();
+        injectors.put( DeleteStoredProcedureParameter.NAME, $nameInjector );
+        injectors.put( DeleteStoredProcedureParameter.DELETED_ENTRY, $deletedEntryInjector
);
+    }
+    
+    public void setDeletedEntryName( Name deletedEntryName )
+    {
+        this.deletedEntryName = deletedEntryName;
+    }
+    
+    MicroInjector $nameInjector = new MicroInjector()
+    {
+        public Object inject() throws NamingException
+        {
+            return deletedEntryName;
+        };
+    };
+    
+    MicroInjector $deletedEntryInjector = new MicroInjector()
+    {
+        public Object inject() throws NamingException
+        {
+            DirectoryPartitionNexusProxy proxy = getInvocation().getProxy();
+            Attributes deletedEntry = proxy.lookup( deletedEntryName, DirectoryPartitionNexusProxy.LOOKUP_BYPASS
);
+            return deletedEntry;
+        };
+    };
+
+}

Added: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/StoredProcedureParameterInjector.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/StoredProcedureParameterInjector.java?rev=405313&view=auto
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/StoredProcedureParameterInjector.java
(added)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/StoredProcedureParameterInjector.java
Mon May  8 22:52:54 2006
@@ -0,0 +1,32 @@
+/*
+ *   Copyright 2006 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+
+package org.apache.directory.server.core.trigger;
+
+import java.util.List;
+
+import javax.naming.NamingException;
+
+public interface StoredProcedureParameterInjector
+{
+    List getArgumentsToInject( List parameterList );
+    
+    public interface MicroInjector
+    {
+        Object inject() throws NamingException;
+    }
+}

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/TriggerService.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/TriggerService.java?rev=405313&r1=405312&r2=405313&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/TriggerService.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/TriggerService.java
Mon May  8 22:52:54 2006
@@ -14,6 +14,7 @@
  *   limitations under the License.
  *
  */
+
 package org.apache.directory.server.core.trigger;
 
 
@@ -21,14 +22,12 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
+import java.util.Map.Entry;
 
 import javax.naming.Name;
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
@@ -42,11 +41,9 @@
 import org.apache.directory.server.core.invocation.Invocation;
 import org.apache.directory.server.core.invocation.InvocationStack;
 import org.apache.directory.server.core.jndi.ServerContext;
-import org.apache.directory.server.core.partition.DirectoryPartitionNexus;
 import org.apache.directory.server.core.partition.DirectoryPartitionNexusProxy;
 import org.apache.directory.server.core.schema.AttributeTypeRegistry;
 import org.apache.directory.server.core.schema.ConcreteNameComponentNormalizer;
-import org.apache.directory.server.core.subtree.SubentryService;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DnParser;
@@ -105,9 +102,10 @@
      * @param entry the target entry that is considered as the trigger source
      * @throws NamingException if there are problems accessing attribute values
      */
-    private void addPrescriptiveTriggerSpecs( DirectoryPartitionNexusProxy proxy, Collection
triggerSpecs,
+    private void addPrescriptiveTriggerSpecs( List triggerSpecs, DirectoryPartitionNexusProxy
proxy,
         Name dn, Attributes entry ) throws NamingException
     {
+        
         /*
          * If the protected entry is a subentry, then the entry being evaluated
          * for perscriptiveTriggerss is in fact the administrative entry.  By
@@ -173,6 +171,62 @@
         }
     }
     
+    public Map getActionTimeMappedTriggerSpecsForOperation( List triggerSpecs, LdapOperation
ldapOperation )
+    {
+        List beforeTriggerSpecs = new ArrayList();
+        List insteadofTriggerSpecs = new ArrayList();
+        List afterTriggerSpecs = new ArrayList();
+        Map triggerSpecMap = new HashMap();
+        
+        Iterator it = triggerSpecs.iterator();
+        while ( it.hasNext() )
+        {
+            TriggerSpecification triggerSpec = ( TriggerSpecification ) it.next();
+            if ( triggerSpec.getLdapOperation().equals( ldapOperation ) )
+            {
+                if ( triggerSpec.getActionTime().equals( ActionTime.BEFORE ) )
+                {
+                    beforeTriggerSpecs.add( triggerSpec );
+                }
+                else if ( triggerSpec.getActionTime().equals( ActionTime.INSTEADOF ) )
+                {
+                    insteadofTriggerSpecs.add( triggerSpec );
+                }
+                else if ( triggerSpec.getActionTime().equals( ActionTime.AFTER ) )
+                {
+                    afterTriggerSpecs.add( triggerSpec );
+                }
+                else
+                {
+                    // TODO
+                }    
+            }
+        }
+        
+        triggerSpecMap.put( ActionTime.BEFORE, beforeTriggerSpecs );
+        triggerSpecMap.put( ActionTime.INSTEADOF, insteadofTriggerSpecs );
+        triggerSpecMap.put( ActionTime.AFTER, afterTriggerSpecs );
+        
+        return triggerSpecMap;
+    }
+    
+    /*private Map getActionTimeMappedStoredProcedures( Map triggerMap )
+    {
+        Map spMap = new HashMap();
+        
+        Iterator it = triggerMap.entrySet().iterator();
+        while ( it.hasNext() )
+        {
+            Map.Entry entry = ( Entry ) it.next();
+            List triggerSpecs = ( List ) entry.getValue();
+            Iterator it = triggerSpecs.iterator();
+            while ( it.hasNext() )
+            {
+                
+            }
+        }
+    }*/
+    
 
     /**
      * Initializes this interceptor based service by getting a handle on the nexus.
@@ -215,45 +269,6 @@
         triggerSpecCache.subentryAdded( normName, entry );
         
     }
-    
-    public Map getActionTimeMappedTriggerSpecs( List triggerSpecs, LdapOperation ldapOperation
)
-    {
-        List beforeTriggerSpecs = new ArrayList();
-        List insteadofTriggerSpecs = new ArrayList();
-        List afterTriggerSpecs = new ArrayList();
-        Map triggerSpecMap = new HashMap();
-        
-        Iterator it = triggerSpecs.iterator();
-        while ( it.hasNext() )
-        {
-            TriggerSpecification triggerSpec = ( TriggerSpecification ) it.next();
-            if ( triggerSpec.getLdapOperation().equals( ldapOperation ) )
-            {
-                if ( triggerSpec.getActionTime().equals( ActionTime.BEFORE ) )
-                {
-                    beforeTriggerSpecs.add( triggerSpec );
-                }
-                else if ( triggerSpec.getActionTime().equals( ActionTime.INSTEADOF ) )
-                {
-                    insteadofTriggerSpecs.add( triggerSpec );
-                }
-                else if ( triggerSpec.getActionTime().equals( ActionTime.AFTER ) )
-                {
-                    afterTriggerSpecs.add( triggerSpec );
-                }
-                else
-                {
-                    // TODO
-                }    
-            }
-        }
-        
-        triggerSpecMap.put( ActionTime.BEFORE, beforeTriggerSpecs );
-        triggerSpecMap.put( ActionTime.INSTEADOF, insteadofTriggerSpecs );
-        triggerSpecMap.put( ActionTime.AFTER, afterTriggerSpecs );
-        
-        return triggerSpecMap;
-    }
 
 
     public void delete( NextInterceptor next, Name name ) throws NamingException
@@ -273,17 +288,19 @@
         }
 
         List triggerSpecs = new ArrayList();
-        addPrescriptiveTriggerSpecs( proxy, triggerSpecs, name, entry );
+        addPrescriptiveTriggerSpecs( triggerSpecs, proxy, name, entry );
         addEntryTriggerSpecs( triggerSpecs, entry );
-        Map triggerMap = getActionTimeMappedTriggerSpecs( triggerSpecs, LdapOperation.DELETE
);
+        Map triggerMap = getActionTimeMappedTriggerSpecsForOperation( triggerSpecs, LdapOperation.DELETE
);
+        // Map spMap = getActionTimeMappedStoredProcedures( triggerMap );
+        
         
         List beforeTriggerSpecs = (List) triggerMap.get( ActionTime.BEFORE );
-        System.out.println( "There are " + beforeTriggerSpecs.size() + " \"BEFORE delete\"
triggers associated with this entry [" + name + "] being deleted:" );
-        System.out.println( ">>> " + beforeTriggerSpecs );
+        log.debug( "There are " + beforeTriggerSpecs.size() + " \"BEFORE delete\" triggers
associated with this entry [" + name + "] being deleted:" );
+        log.debug( ">>> " + beforeTriggerSpecs );
         
         List insteadofTriggerSpecs = (List) triggerMap.get( ActionTime.INSTEADOF );
-        System.out.println( "There are " + insteadofTriggerSpecs.size() + " \"INSTEADOF delete\"
triggers associated with this entry [" + name + "] being deleted:" );
-        System.out.println( ">>> " + insteadofTriggerSpecs );
+        log.debug( "There are " + insteadofTriggerSpecs.size() + " \"INSTEADOF delete\" triggers
associated with this entry [" + name + "] being deleted:" );
+        log.debug( ">>> " + insteadofTriggerSpecs );
         
         if ( insteadofTriggerSpecs.size() == 0 )
         {
@@ -293,13 +310,12 @@
         }
         else
         {
-            System.out.println ("Delete operation has not been performed due to the INSTEADOF
trigger(s).");
+            log.debug("Delete operation has not been performed due to the INSTEADOF trigger(s).");
         }
         
         List afterTriggerSpecs = (List) triggerMap.get( ActionTime.AFTER );
-        System.out.println( "There are " + afterTriggerSpecs.size() + " \"AFTER delete\"
triggers associated with this entry [" + name + "] being deleted:" );
-        System.out.println( ">>> " + afterTriggerSpecs );
-        System.out.println();
+        log.debug( "There are " + afterTriggerSpecs.size() + " \"AFTER delete\" triggers
associated with this entry [" + name + "] being deleted:" );
+        log.debug( ">>> " + afterTriggerSpecs );
     }
 
 }

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/TriggerSpecCache.java
URL: http://svn.apache.org/viewcvs/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/TriggerSpecCache.java?rev=405313&r1=405312&r2=405313&view=diff
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/TriggerSpecCache.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/trigger/TriggerSpecCache.java
Mon May  8 22:52:54 2006
@@ -14,6 +14,7 @@
  *   limitations under the License.
  *
  */
+
 package org.apache.directory.server.core.trigger;
 
 



Mime
View raw message