You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by sy...@apache.org on 2005/10/10 16:58:51 UTC

svn commit: r312661 - in /cocoon/branches/BRANCH_2_1_X/src: blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java java/org/apache/cocoon/environment/ObjectModelHelper.java

Author: sylvain
Date: Mon Oct 10 07:58:44 2005
New Revision: 312661

URL: http://svn.apache.org/viewcvs?rev=312661&view=rev
Log:
Deprecating ObjectModelHelper.getCookie()

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/ObjectModelHelper.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java?rev=312661&r1=312660&r2=312661&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/databases/java/org/apache/cocoon/acting/DatabaseCookieAuthenticatorAction.java Mon Oct 10 07:58:44 2005
@@ -20,6 +20,7 @@
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.Constants;
+import org.apache.cocoon.environment.Cookie;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Redirector;
 import org.apache.cocoon.environment.Request;
@@ -264,7 +265,7 @@
                  *  but not the value, we exit immediately do
                  *  that authorization fails authomatically
                  */
-                cookie_value = ObjectModelHelper.getCookie(objectModel, cookie_name, -1).getValue();
+                cookie_value = getCookie(objectModel, cookie_name).getValue();
 
                 if (cookie_value == null || cookie_value.trim().equals("")) {
                     // value is null
@@ -293,6 +294,23 @@
             getLogger().error("Exception: ",e);
             return null;
         }
+    }
+
+    public static Cookie getCookie(Map objectModel, String cookieName) {
+        
+        Request request = ObjectModelHelper.getRequest(objectModel);
+        
+        Cookie[] cookies = request.getCookies();
+        if (cookies != null) {
+            for(int count = 0; count < cookies.length; count++) {
+                Cookie currentCookie = cookies[count];
+                if (currentCookie.getName().equals(cookieName)) {
+                    return currentCookie;
+                }
+            }
+        }
+        
+        return null;
     }
 
     /**

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/ObjectModelHelper.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/ObjectModelHelper.java?rev=312661&r1=312660&r2=312661&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/ObjectModelHelper.java (original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/environment/ObjectModelHelper.java Mon Oct 10 07:58:44 2005
@@ -17,6 +17,8 @@
 
 import java.util.Map;
 
+import org.apache.cocoon.util.Deprecation;
+
 /**
  * A set of constants and methods to access the content of the object model.
  * <p>
@@ -83,21 +85,13 @@
     }
     
     /**
-     * Method used to return a cookie object based on the name or the index that was passed
-     *
-     * If both name and index of cookie to be extracted is passed in, name will take
-     * precedence. Basic thing followed is that, when name is passed, index should be -1 and
-     * when index is passed name should null
-     *
-     * @param objectModel
-     * @param cookieName Name of the cookie which is to be found and returned back
-     * @param cookieIndex Index of the cookie which is to be found and returned
-     * @return cookie object is returned
+     * @deprecated Don't use this method which should never have been there
      * @since 2.1.7
      */
     public static Cookie getCookie(Map objectModel,
                                    String cookieName,
                                    int cookieIndex) {
+        Deprecation.logger.error("ObjectModelHelper.getCookie() should not be used, and will be removed in the next release");
         boolean retrieveByName = false;
         boolean retrieveByIndex = false;
         boolean matchFound = false;