balld       01/07/10 11:52:28

  Modified:    src/org/apache/cocoon/transformation TraxTransformer.java
  Log:
  add the possibility to import cookies as parameters
  
  Revision  Changes    Path
  1.24      +32 -4     
xml-cocoon2/src/org/apache/cocoon/transformation/TraxTransformer.java
  
  Index: TraxTransformer.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/TraxTransformer.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- TraxTransformer.java      2001/07/07 11:43:36     1.23
  +++ TraxTransformer.java      2001/07/10 18:52:25     1.24
  @@ -46,6 +46,7 @@
   import org.apache.cocoon.components.browser.Browser;
   import org.apache.cocoon.components.store.Store;
   import org.apache.cocoon.environment.Request;
  +import org.apache.cocoon.environment.Cookie;
   import org.apache.cocoon.environment.Source;
   import org.apache.cocoon.environment.SourceResolver;
   import org.apache.cocoon.util.HashUtil;
  @@ -99,7 +100,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Davanum Srinivas</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Carsten Ziegeler</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Giacomo Pati</a>
  - * @version CVS $Id: TraxTransformer.java,v 1.23 2001/07/07 11:43:36 giacomo Exp $
  + * @version CVS $Id: TraxTransformer.java,v 1.24 2001/07/10 18:52:25 balld Exp $
    */
   public class TraxTransformer extends ContentHandlerWrapper
   implements Transformer, Composable, Recyclable, Configurable, Cacheable, 
Disposable, URIResolver {
  @@ -125,6 +126,10 @@
       private boolean useParameters = false;
       private boolean _useParameters = false;
   
  +    /** Should we make the cookies availalbe in the stylesheet? (default is off) **/
  +    private boolean useCookies = false;
  +    private boolean _useCookies = false;
  +
       /** Should we make the browser capability properties available in the 
stylesheet? (default is off) */
       private boolean useBrowserCap = false;
       private boolean _useBrowserCap = false;
  @@ -307,6 +312,10 @@
               this.useParameters = child.getValueAsBoolean(false);
               this._useParameters = this.useParameters;
               getLogger().debug("Use parameters is " + this.useParameters + " for " + 
this);
  +            child = conf.getChild("use-cookies");
  +            this.useCookies = child.getValueAsBoolean(false);
  +            this._useCookies = this.useCookies;
  +            getLogger().debug("Use cookies is " + this.useCookies + " for " + this);
               child = conf.getChild("use-browser-capabilities-db");
               this.useBrowserCap = child.getValueAsBoolean(false);
               this._useBrowserCap = this.useBrowserCap;
  @@ -348,6 +357,7 @@
           this.resolver = resolver;
           getLogger().debug("Using stylesheet: '"+this.inputSource.getSystemId()+"' 
in " + this + ", last modified: " + this.inputSource.getLastModified());
           _useParameters = par.getParameterAsBoolean("use-request-parameters", 
this.useParameters);
  +        _useCookies = par.getParameterAsBoolean("use-cookies", this.useCookies);
           _useBrowserCap = par.getParameterAsBoolean("use-browser-capabilities-db", 
this.useBrowserCap);
       }
   
  @@ -392,9 +402,9 @@
                   return new 
TimeStampCacheValidity(this.inputSource.getLastModified());
               } else {
                   return new CompositeCacheValidity(
  -                                    new ParametersCacheValidity(map),
  -                                    new 
TimeStampCacheValidity(this.inputSource.getLastModified())
  -                                    );
  +                    new ParametersCacheValidity(map),
  +                    new TimeStampCacheValidity(this.inputSource.getLastModified())
  +                );
               }
           }
           return null;
  @@ -483,6 +493,23 @@
               }
           }
   
  +        if (this._useCookies) {
  +            Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
  +            Cookie cookies[] = request.getCookies();
  +            if (cookies != null) {
  +                for (int i=0; i<cookies.length; i++) {
  +                    String name = cookies[i].getName();
  +                    if (isValidXSLTParameterName(name)) {
  +                        String value = cookies[i].getValue();
  +                        if (map == null) {
  +                            map = new HashMap();
  +                        }
  +                        map.put(name,value);
  +                    }
  +                }
  +            }
  +        }
  +
           if (this._useBrowserCap) try {
               Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT);
               if (map == null) {
  @@ -604,6 +631,7 @@
           this.par = null;
           this.resolver = null;
           this._useParameters = this.useParameters;
  +        this._useCookies = this.useCookies;
           this._useBrowserCap = this.useBrowserCap;
           super.recycle();
       }
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to