directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r569075 - in /directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context: AbstractOperationContext.java EmptyOperationContext.java OperationContext.java
Date Thu, 23 Aug 2007 17:11:53 GMT
Author: akarasulu
Date: Thu Aug 23 10:11:52 2007
New Revision: 569075

URL: http://svn.apache.org/viewvc?rev=569075&view=rev
Log:
adding request and response controls to the operation context so controls can be queried and
used within the servers core and added in responses

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/EmptyOperationContext.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java?rev=569075&r1=569074&r2=569075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/AbstractOperationContext.java
Thu Aug 23 10:11:52 2007
@@ -19,8 +19,14 @@
  */
 package org.apache.directory.server.core.interceptor.context;
 
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.naming.ldap.Control;
+
 import org.apache.directory.shared.ldap.name.LdapDN;
 
+
 /**
  * This abstract class stores common context elements, like the DN, which is used
  * in all the contexts.
@@ -28,10 +34,13 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class AbstractOperationContext implements OperationContext
+public abstract class AbstractOperationContext implements OperationContext
 {
     /** The DN associated with the context */
     private LdapDN dn;
+    private Map<String, Control> requestControls = new HashMap<String, Control>(2);
+    private Map<String, Control> responseControls = new HashMap<String, Control>(2);
+    
     
     /**
      * 
@@ -42,6 +51,7 @@
     {
     }
 
+    
     /**
      * 
      * Creates a new instance of AbstractOperationContext.
@@ -53,6 +63,7 @@
         this.dn = dn;
     }
 
+    
     /**
      * @return The associated DN
      */
@@ -61,6 +72,7 @@
         return dn;
     }
 
+    
     /**
      * Set the context DN
      *
@@ -69,5 +81,41 @@
     public void setDn( LdapDN dn )
     {
         this.dn = dn;
+    }
+
+    
+    public void addRequestControl( Control requestControl )
+    {
+        requestControls.put( requestControl.getID(), requestControl );
+    }
+
+    
+    public Control getRequestControl( String numericOid )
+    {
+        return requestControls.get( numericOid );
+    }
+
+    
+    public boolean hasRequestControl( String numericOid )
+    {
+        return requestControls.containsKey( numericOid );
+    }
+
+
+    public void addResponseControl( Control responseControl )
+    {
+        responseControls.put( responseControl.getID(), responseControl );
+    }
+
+
+    public Control getResponseControl( String numericOid )
+    {
+        return responseControls.get( numericOid );
+    }
+
+
+    public boolean hasResponseControl( String numericOid )
+    {
+        return responseControls.containsKey( numericOid );
     }
 }

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/EmptyOperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/EmptyOperationContext.java?rev=569075&r1=569074&r2=569075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/EmptyOperationContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/EmptyOperationContext.java
Thu Aug 23 10:11:52 2007
@@ -28,24 +28,17 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class EmptyOperationContext implements OperationContext
+public class EmptyOperationContext extends AbstractOperationContext
 {
     /**
      * Creates a new instance of EmptyOperationContext.
      */
     public EmptyOperationContext()
     {
-        super();
-    }
-    
-    /**
-     * @return The associated DN
-     */
-    public LdapDN getDn()
-    {
-        return LdapDN.EMPTY_LDAPDN;
+        super( LdapDN.EMPTY_LDAPDN );
     }
     
+
     /**
      * Set the context DN
      *
@@ -53,9 +46,16 @@
      */
     public void setDn( LdapDN dn )
     {
-        // do nothing
+        if ( dn.equals( LdapDN.EMPTY_LDAPDN ) )
+        {
+            return;
+        }
+        
+        throw new UnsupportedOperationException( 
+            "Cannot set the empty operation context to anything other than the EmptyDN" );
     }
 
+    
     /**
      * @see Object#toString()
      */

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java?rev=569075&r1=569074&r2=569075&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/interceptor/context/OperationContext.java
Thu Aug 23 10:11:52 2007
@@ -19,8 +19,12 @@
  */
 package org.apache.directory.server.core.interceptor.context;
 
+
+import javax.naming.ldap.Control;
+
 import org.apache.directory.shared.ldap.name.LdapDN;
 
+
 /**
  * This interface represent the context passed as an argument to each interceptor.
  * It will contain data used by all the operations.
@@ -35,6 +39,7 @@
      */
     LdapDN getDn();
     
+    
     /**
      * Set the context DN
      *
@@ -42,4 +47,55 @@
      */
     void setDn( LdapDN dn );
 
+    
+    /**
+     * Adds a response control to this operation.
+     *
+     * @param responseControl the response control to add to this operation.
+     */
+    void addResponseControl( Control responseControl );
+    
+    
+    /** 
+     * Checks to see if a response control is present on this operation.
+     *
+     * @param numericOid the numeric OID of the control also known as it's type OID
+     * @return true if the control is associated with this operation, false otherwise
+     */
+    boolean hasResponseControl( String numericOid );
+    
+    
+    /**
+     * Gets a response control if present for this request.
+     * 
+     * @param numericOid the numeric OID of the control also known as it's type OID
+     * @return the control if present
+     */
+    Control getResponseControl( String numericOid );
+    
+    
+    /**
+     * Adds a request control to this operation.
+     *
+     * @param requestControl the request control to add to this operation.
+     */
+    void addRequestControl( Control requestControl );
+    
+    
+    /** 
+     * Checks to see if a request control is present on this request.
+     *
+     * @param numericOid the numeric OID of the control also known as it's type OID
+     * @return true if the control is associated with this operation, false otherwise
+     */
+    boolean hasRequestControl( String numericOid );
+    
+    
+    /**
+     * Gets a request control if present for this request.
+     * 
+     * @param numericOid the numeric OID of the control also known as it's type OID
+     * @return the control if present
+     */
+    Control getRequestControl( String numericOid );
 }



Mime
View raw message