commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http SessionTag.java Proxy.java OptionsTag.java HttpTagSupport.java BodyTag.java HeadTag.java ParameterTag.java GetTag.java DeleteTag.java HttpTagLibrary.java PutTag.java PostTag.java HeaderTag.java
Date Fri, 27 Sep 2002 02:07:55 GMT
dion        2002/09/26 19:07:54

  Modified:    jelly/src/java/org/apache/commons/jelly/tags/http
                        GetTag.java DeleteTag.java HttpTagLibrary.java
                        PutTag.java PostTag.java HeaderTag.java
  Added:       jelly/src/java/org/apache/commons/jelly/tags/http
                        SessionTag.java Proxy.java OptionsTag.java
                        HttpTagSupport.java BodyTag.java HeadTag.java
                        ParameterTag.java
  Log:
  Move Latka HTTP Tag library over to Jelly
  
  Revision  Changes    Path
  1.2       +30 -17    jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/GetTag.java
  
  Index: GetTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/GetTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GetTag.java	24 Jun 2002 11:17:09 -0000	1.1
  +++ GetTag.java	27 Sep 2002 02:07:54 -0000	1.2
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -56,29 +56,42 @@
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - * 
  - * $Id$
  + *
    */
  +
   package org.apache.commons.jelly.tags.http;
   
   import java.net.MalformedURLException;
   
  -import org.apache.commons.httpclient.HttpException;
  -import org.apache.commons.httpclient.HttpMethod;
  +import org.apache.commons.httpclient.HttpUrlMethod;
   import org.apache.commons.httpclient.methods.UrlGetMethod;
   
  -/** 
  - * Performs a HTTP GET request fron a given URL.
  +/**
  + * A http get tag
    *
  - * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  - * @version $Revision$
  + * @author  dion
  + * @version $Id$
    */
  -public class GetTag extends MethodSupportTag {
  -
  +public class GetTag extends HttpTagSupport {
  +    
  +    /** the get method */
  +    private UrlGetMethod _getMethod;
  +    
  +    /**
  +     * Creates a new instance of GetTag
  +     */
  +    public GetTag() {
  +    }
  +    
       /**
  -     * @return the HTTP method to invoke
  +     * @return a url method for a get request
  +     * @throws MalformedURLException when the url is bad
        */
  -    public HttpMethod getMethod() throws HttpException, MalformedURLException {
  -        return new UrlGetMethod(getUrl());
  +    protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
  +        if (_getMethod == null) {
  +            _getMethod = new UrlGetMethod(getResolvedUrl());
  +        }
  +        return _getMethod;
       }
  +        
   }
  
  
  
  1.2       +30 -17    jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/DeleteTag.java
  
  Index: DeleteTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/DeleteTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeleteTag.java	24 Jun 2002 11:17:09 -0000	1.1
  +++ DeleteTag.java	27 Sep 2002 02:07:54 -0000	1.2
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -56,29 +56,42 @@
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - * 
  - * $Id$
  + *
    */
  +
   package org.apache.commons.jelly.tags.http;
   
   import java.net.MalformedURLException;
   
  -import org.apache.commons.httpclient.HttpException;
  -import org.apache.commons.httpclient.HttpMethod;
  +import org.apache.commons.httpclient.HttpUrlMethod;
   import org.apache.commons.httpclient.methods.UrlDeleteMethod;
   
  -/** 
  - * Performs a HTTP POST request fron a given URL.
  +/**
  + * A http delete tag
    *
  - * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  - * @version $Revision$
  + * @author  dion
  + * @version $Id$
    */
  -public class DeleteTag extends MethodSupportTag {
  -
  +public class DeleteTag extends HttpTagSupport {
  +    
  +    /** the delete method */
  +    private UrlDeleteMethod _deleteMethod;
  +    
  +    /**
  +     * Creates a new instance of DeleteTag
  +     */
  +    public DeleteTag() {
  +    }
  +    
       /**
  -     * @return the HTTP method to invoke
  +     * @return a url method for a get request
  +     * @throws MalformedURLException when the url is bad
        */
  -    public HttpMethod getMethod() throws HttpException, MalformedURLException {
  -        return new UrlDeleteMethod(getUrl());
  +    protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
  +        if (_deleteMethod == null) {
  +            _deleteMethod = new UrlDeleteMethod(getResolvedUrl());
  +        }
  +        return _deleteMethod;
       }
  +        
   }
  
  
  
  1.2       +37 -15    jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/HttpTagLibrary.java
  
  Index: HttpTagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/HttpTagLibrary.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HttpTagLibrary.java	24 Jun 2002 11:17:09 -0000	1.1
  +++ HttpTagLibrary.java	27 Sep 2002 02:07:54 -0000	1.2
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -56,25 +56,47 @@
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - * 
  - * $Id$
  + *
    */
  +
   package org.apache.commons.jelly.tags.http;
   
  +import java.util.Map;
  +
   import org.apache.commons.jelly.TagLibrary;
   
  -/** Describes the Taglib. This class could be generated by XDoclet
  -  *
  -  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision$
  -  */
  +/**
  + * The set of jelly tags provided by Latka
  + *
  + * @author dion
  + * @version $Id$
  + */
   public class HttpTagLibrary extends TagLibrary {
  -
  +    
  +    /** 
  +     * Creates a new instance of LatkaTagLibrary
  +     */
       public HttpTagLibrary() {
  -        registerTag("delete", DeleteTag.class);
  +        registerTag("session", SessionTag.class);
           registerTag("get", GetTag.class);
  -        registerTag("header", HeaderTag.class);
  -        registerTag("post", GetTag.class);
  +        registerTag("post", PostTag.class);
  +        registerTag("delete", DeleteTag.class);
  +        registerTag("head", HeadTag.class);
  +        registerTag("options", OptionsTag.class);
           registerTag("put", PutTag.class);
  +        registerTag("parameter", ParameterTag.class);
  +        registerTag("header", HeaderTag.class);
  +        registerTag("body", BodyTag.class);
  +    }
  +    
  +    /**
  +     * @see TagLibarary#getTagClasses()
  +     *
  +     * @return a Map of tag name to tag class
  +     */
  +    public Map getTagClasses() {
  +        return super.getTagClasses();
       }
  +    
   }
  +
  
  
  
  1.2       +48 -17    jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/PutTag.java
  
  Index: PutTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/PutTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PutTag.java	24 Jun 2002 11:17:09 -0000	1.1
  +++ PutTag.java	27 Sep 2002 02:07:54 -0000	1.2
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -56,29 +56,60 @@
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - * 
  - * $Id$
  + *
    */
  +
   package org.apache.commons.jelly.tags.http;
   
   import java.net.MalformedURLException;
  -
  -import org.apache.commons.httpclient.HttpException;
  -import org.apache.commons.httpclient.HttpMethod;
  +import org.apache.commons.httpclient.HttpUrlMethod;
   import org.apache.commons.httpclient.methods.UrlPutMethod;
   
  -/** 
  - * Performs a HTTP POST request fron a given URL.
  +
  +/**
  + * A http put
    *
  - * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  - * @version $Revision$
  + * @author  dion
  + * @version $Id$
    */
  -public class PutTag extends MethodSupportTag {
  +public class PutTag extends HttpTagSupport {
  +    
  +    /** the put method */
  +    private UrlPutMethod _putMethod;
   
  +    /** Creates a new instance of PutTag */
  +    public PutTag() {
  +    }
  +    
  +    /** 
  +     * Return a {@link HttpUrlMethod method} to be used for put'ing
  +     *
  +     * @return a HttpUrlMethod implementation
  +     * @throws MalformedURLException when the {@link getUrl() url} or
  +     * {@link #getPath() path} is invalid
  +     */
  +    protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
  +        if (_putMethod == null) {
  +            _putMethod = new UrlPutMethod(getResolvedUrl());
  +        }
  +        return _putMethod;
  +    }
  +    
  +    /** 
  +     * Set the current parameters on the url method ready for processing
  +     *
  +     */
  +    protected void setParameters() {
  +    }
  +    
       /**
  -     * @return the HTTP method to invoke
  +     * Fail as PUT requests don't have parameters
  +     *
  +     * @param name the parameter name
  +     * @param value the parameter value
        */
  -    public HttpMethod getMethod() throws HttpException, MalformedURLException {
  -        return new UrlPutMethod(getUrl());
  +    public void addParameter(String name, String value) {
  +        throw new IllegalArgumentException("PUT requests don't have params");
       }
  +
   }
  
  
  
  1.2       +47 -18    jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/PostTag.java
  
  Index: PostTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/PostTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PostTag.java	24 Jun 2002 11:17:09 -0000	1.1
  +++ PostTag.java	27 Sep 2002 02:07:54 -0000	1.2
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -56,29 +56,58 @@
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - * 
  - * $Id$
  + *
    */
  +
   package org.apache.commons.jelly.tags.http;
   
   import java.net.MalformedURLException;
  -
  -import org.apache.commons.httpclient.HttpException;
  -import org.apache.commons.httpclient.HttpMethod;
  +import org.apache.commons.httpclient.HttpUrlMethod;
  +import org.apache.commons.httpclient.NameValuePair;
   import org.apache.commons.httpclient.methods.UrlPostMethod;
   
  -/** 
  - * Performs a HTTP POST request fron a given URL.
  +
  +/**
  + * A http post
    *
  - * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  - * @version $Revision$
  + * @author  dion
    */
  -public class PostTag extends MethodSupportTag {
  +public class PostTag extends HttpTagSupport {
  +    
  +    /** the post method */
  +    private UrlPostMethod _postMethod;
   
  -    /**
  -     * @return the HTTP method to invoke
  +    /** Creates a new instance of PostTag */
  +    public PostTag() {
  +    }
  +    
  +    /** 
  +     * Return a {@link HttpUrlMethod method} to be used for post'ing
  +     *
  +     * @return a HttpUrlMethod implementation
  +     * @throws MalformedURLException when the {@link getUrl() url} or
  +     * {@link #getPath() path} is invalid
  +     */
  +    protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
  +        if (_postMethod == null) {
  +            _postMethod = new UrlPostMethod(getResolvedUrl());
  +        }
  +        return _postMethod;
  +    }
  +    
  +    /** 
  +     * Set the current parameters on the url method ready for processing
  +     *
  +     * This method <strong>must</strong> be called after 
  +     *  {@link getHttpUrlMethod}
        */
  -    public HttpMethod getMethod() throws HttpException, MalformedURLException {
  -        return new UrlPostMethod(getUrl());
  +    protected void setParameters() {
  +        NameValuePair nvp = null;
  +        for (int index = 0; index < getParameters().size(); index++) {
  +            NameValuePair parameter = (NameValuePair) getParameters().
  +                get(index);
  +            _postMethod.addParameter(parameter);
  +        }
       }
  +
   }
  
  
  
  1.2       +64 -47    jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/HeaderTag.java
  
  Index: HeaderTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/HeaderTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HeaderTag.java	24 Jun 2002 11:17:09 -0000	1.1
  +++ HeaderTag.java	27 Sep 2002 02:07:54 -0000	1.2
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -56,63 +56,80 @@
    * individuals on behalf of the Apache Software Foundation.  For more
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
  - * 
  - * $Id$
  + *
    */
   
   package org.apache.commons.jelly.tags.http;
   
  -import org.apache.commons.jelly.JellyException;
  -import org.apache.commons.jelly.MissingAttributeException;
   import org.apache.commons.jelly.TagSupport;
   import org.apache.commons.jelly.XMLOutput;
   
  -/** Defines a header on an outer HTTP tag
  -  *
  -  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision$
  -  */
  +/**
  + * A tag to hold request headers
  + * 
  + * @author  dion
  + * @version $Id$
  + */
   public class HeaderTag extends TagSupport {
  -
  -    /** Stores the name of the property */
  -    private String name;
  -    
  -    /** Stores the value of the property */
  -    private Object value;
  -    
  +    /** parameter name */
  +    private String _name;
  +    /** parameter value */
  +    private String _value;
       
  -    // Tag interface
  -    //-------------------------------------------------------------------------                    
  -    public void doTag(XMLOutput output) throws Exception {
  -        if ( name == null ) {
  -            throw new MissingAttributeException("name");
  -        }
  -        MethodSupportTag tag = (MethodSupportTag) findAncestorWithClass( MethodSupportTag.class );
  -        if ( tag == null ) {
  -            throw new JellyException("<http:header> tag must be within a <http:method> tag");
  -        }
  -        
  -        if ( value != null ) {
  -            tag.addHeader(name, value.toString());
  -        }
  -        else {
  -            tag.addHeader(name, getBodyText());
  -        }
  +    /** Creates a new instance of HeaderTag */
  +    public HeaderTag() {
       }
   
  +    /**
  +     * Perform the tag functionality. In this case, simply evaluate the body.
  +     *
  +     * @param xmlOutput where to send output
  +     * @throws Exception when an error occurs
  +     */
  +    public void doTag(XMLOutput xmlOutput) throws Exception {
  +        HttpTagSupport http = (HttpTagSupport) findAncestorWithClass(
  +            HttpTagSupport.class);
  +        http.addRequestHeader(getName(), getValue());
  +        invokeBody(xmlOutput);
  +    }
  +
  +    //--------------------------------------------------------------------------
  +    // Property accessors/mutators
  +    //--------------------------------------------------------------------------
  +    /**
  +     * Getter for property name.
  +     *
  +     * @return Value of property name.
  +     */
  +    public String getName() {
  +        return _name;
  +    }
       
  -    // Properties
  -    //-------------------------------------------------------------------------                    
  -    /** Sets the name of the JMS property
  -      */
  +    /**
  +     * Setter for property name.
  +     *
  +     * @param name New value of property name.
  +     */
       public void setName(String name) {
  -        this.name = name;
  +        _name = name;
       }
       
  -    /** Sets the value of the JMS property. 
  -      * If no value is set then the body of the tag is used
  -      */
  -    public void setValue(Object value) {
  -        this.value = value;
  +    /**
  +     * Getter for property value.
  +     *
  +     * @return Value of property value.
  +     */
  +    public String getValue() {
  +        return _value;
       }
  +    
  +    /**
  +     * Setter for property value.
  +     *
  +     * @param value New value of property value.
  +     */
  +    public void setValue(String value) {
  +        _value = value;
  +    }
  +    
   }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/SessionTag.java
  
  Index: SessionTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/SessionTag.java,v 1.8 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.8 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.http;
  
  import org.apache.commons.httpclient.HttpMultiClient;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /**
   * A http session. This is the container for data shared across requests
   *
   * @author dion
   */
  public class SessionTag extends TagSupport {
      
      /** default host for requests */
      private String _host;
      /** default port for requests */
      private String _port;
      /** Proxy details for requests */
      private Proxy _proxy = new Proxy();
      /** whether the default is for secure comms */
      private boolean _secure;
      /** the browser identifier */
      private String _userAgent;
      /** strict compliance */
      private boolean _strictMode = false;
      
      /** http client used to store state and execute requests */
      private HttpMultiClient _httpClient;
      
      /** 
       * Creates a new instance of SessionTag
       */
      public SessionTag() {
      }
      
      /**
       * Process the tag
       *
       * @param xmlOutput to write output
       * @throws Exception when any error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          if (isProxyAvailable()) {
              _httpClient = new HttpMultiClient(getProxyHost(), getProxyPort());
          } else {
              _httpClient = new HttpMultiClient();
          }
          
          invokeBody(xmlOutput);
      }
      
      /**
       * Getter for property httpClient.
       *
       * @return Value of property httpClient.
       */
      public HttpMultiClient getHttpClient() {
          return _httpClient;
      }
      
      /**
       * Setter for property httpClient.
       *
       * @param httpClient New value of property httpClient.
       */
      public void setHttpClient(HttpMultiClient httpClient) {
          _httpClient = httpClient;
      }
      /**
       * Tests whether the {@link #getProxy() proxy} is ready for use
       *
       * @return true if the {@link #getProxy() proxy} is configured for use
       */
      public boolean isProxyAvailable() {
          return getProxy() != null && getProxy().getHost() != null 
              && getProxy().getPort() != Proxy.PORT_UNSPECIFIED;
      }
      
      /**
       * Helper method for proxy host property
       *
       * @return the {@link #getProxy() proxy's} host property
       */
      public String getProxyHost() {
          return getProxy().getHost();
      }
      
      /**
       * Helper method for proxy <code>host</code> property
       *
       * @param host the {@link #getProxy() proxy's} host property
       */
      public void setProxyHost(String host) {
          getProxy().setHost(host);
      }
      
      /**
       * Helper method for proxy <code>port</code> property
       *
       * @return the {@link #getProxy() proxy's} port property
       */
      public int getProxyPort() {
          return getProxy().getPort();
      }
      
      /**
       * Helper method for proxy <code>port</code> property
       *
       * @param port the {@link #getProxy() proxy's} port property
       */
      public void setProxyPort(int port) {
          getProxy().setPort(port);
      }
      
      /**
       * Getter for property host.
       *
       * @return Value of property host.
       */
      public String getHost() {
          return _host;
      }
      
      /**
       * Setter for property host.
       *
       * @param host New value of property host.
       */
      public void setHost(String host) {
          _host = host;
      }
      
      /** Getter for property port.
       * @return Value of property port.
       */
      public String getPort() {
          return _port;
      }
      
      /** Setter for property port.
       * @param port New value of property port.
       */
      public void setPort(String port) {
          _port = port;
      }
      
      /**
       * Getter for property proxy.
       *
       * @return Value of property proxy.
       */
      public Proxy getProxy() {
          return _proxy;
      }
      
      /**
       * Setter for property proxy.
       *
       * @param proxy New value of property proxy.
       */
      public void setProxy(Proxy proxy) {
          _proxy = proxy;
      }
      
      /**
       * Getter for property secure.
       *
       * @return Value of property secure.
       */
      public boolean isSecure() {
          return _secure;
      }
      
      /**
       * Setter for property secure.
       *
       * @param secure New value of property secure.
       */
      public void setSecure(boolean secure) {
          _secure = secure;
      }
  
      /** Getter for property userAgent.
       * @return Value of property userAgent.
       */
      public String getUserAgent() {
          return _userAgent;
      }
      
      /** Setter for property userAgent.
       * @param userAgent New value of property userAgent.
       */
      public void setUserAgent(String userAgent) {
          _userAgent = userAgent;
      }
      
      /** Getter for property strictMode.
       * @return Value of property strictMode.
       */
      public boolean isStrictMode() {
          return _strictMode;
      }
      
      /** Setter for property strictMode.
       * @param strictMode New value of property strictMode.
       */
      public void setStrictMode(boolean strictMode) {
          _strictMode = strictMode;
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/Proxy.java
  
  Index: Proxy.java
  ===================================================================
  /*
   *
   *
   *
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.http;
  
  /**
   * A class that holds proxy details for a session. 
   * At the moment this is a placeholder for two simple properties that may
   * get added to as time goes by
   *
   * @author  dion
   * @version $Id: Proxy.java,v 1.3 2002/07/04 14:06:32 dion Exp $
   */
  public class Proxy {
      
      /** the host to use as a proxy */
      private String _host;
      /** the port to send proxied requests on */
      private int _port;
      /** the port number that represents port is unassigned */
      public static final int PORT_UNSPECIFIED = -1;
      
      /**
       * Creates a new instance of Proxy
       */
      public Proxy() {
          this(null, Proxy.PORT_UNSPECIFIED);
      }
      
      /** 
       * Create a proxy given a host name and port number .
       *
       * @param host the host name of the proxy to be used.
       * @param port the port to send proxied requests on.
       */
      public Proxy(String host, int port) {
          setHost(host);
          setPort(port);
      }
      
      /**
       * Getter for property host.
       *
       * @return the host name of the proxy to be used.
       */
      public String getHost() {
          return _host;
      }
      
      /**
       * Setter for property host.
       *
       * @param host the host name of the proxy to be used.
       */
      public void setHost(String host) {
          _host = host;
      }
      
      /**
       * Getter for property port.
       *
       * @return the port to send proxied requests on.
       */
      public int getPort() {
          return _port;
      }
      
      /**
       * Setter for property port.
       *
       * @param port the port to send proxied requests on.
       */
      public void setPort(int port) {
          _port = port;
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/OptionsTag.java
  
  Index: OptionsTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/OptionsTag.java,v 1.2 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.2 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.http;
  
  import java.net.MalformedURLException;
  
  import org.apache.commons.httpclient.HttpUrlMethod;
  import org.apache.commons.httpclient.methods.UrlOptionsMethod;
  
  /**
   * A http get tag
   *
   * @author  dion
   * @version $Id: OptionsTag.java,v 1.2 2002/07/14 12:38:22 dion Exp $
   */
  public class OptionsTag extends HttpTagSupport {
      
      /** the options method */
      private UrlOptionsMethod _optionsMethod;
      
      /**
       * Creates a new instance of OptionsTag
       */
      public OptionsTag() {
      }
      
      /**
       * @return a url method for an options request
       * @throws MalformedURLException when the url is bad
       */
      protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
          if (_optionsMethod == null) {
              _optionsMethod = new UrlOptionsMethod(getResolvedUrl());
          }
          return _optionsMethod;
      }
          
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/HttpTagSupport.java
  
  Index: HttpTagSupport.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/HttpTagSupport.java,v 1.3 2002/07/14 16:51:33 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 16:51:33 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.http;
  
  import java.net.MalformedURLException;
  import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.commons.httpclient.HttpMultiClient;
  import org.apache.commons.httpclient.HttpUrlMethod;
  import org.apache.commons.httpclient.NameValuePair;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /**
   * The base tag for all http requests
   *
   * @author  dion
   * @version $Id: HttpTagSupport.java,v 1.3 2002/07/14 16:51:33 dion Exp $
   */
  public abstract class HttpTagSupport extends TagSupport {
      
      /** unique identifier of the tag/ variable to store result in */
      private String _var;
  
      /**
       * the path to be tested relative to the host/port specifed on the parent
       * {@link SuiteTag suite tag}. 
       * Either this property and the suite's host
       * must be provided, or the {@link #getUrl() url} property must be specifed
       */
      private String _path;
      
      /**
       * The complete uri to be processed
       * Either this property or the {@link #getPath() path} and the suite's host
       * must be provided.
       */
      private String _uri;
      
      /** whether or not to follow redirects */ 
      private boolean _followRedirects = true;
      /** list of parameters as name value pairs */
      private List _parameters;
      /** list of headers as name value pairs */
      private List _requestHeaders;
      /** the header name for the user agent */
      private static final String HEADER_NAME_USER_AGENT = "User-Agent";
      
      /**
       * Creates a new instance of HttpTag
       */
      public HttpTagSupport() {
          setParameters(new ArrayList());
          setRequestHeaders(new ArrayList());
      }
      
      /**
       * @return the url specified by the tag, either the url if not null, or
       * a combination of the host, port and path
       */
      public String getResolvedUrl() {
          if (getUri() != null) {
              return getUri();
          } else {
              // build it from path, host and optionally port
              SessionTag session = (SessionTag) findAncestorWithClass(
                  SessionTag.class);
              String host = session.getHost();
              String port = session.getPort();
              // short term hack, need to add port and security in
              return "http://" + host + getPath();
          }
      }
      
      /**
       * A method that must be implemented by subclasses to provide the 
       * {@link HttpUrlMethod url method} implementation
       *
       * @return a HttpUrlMethod implementation
       * @throws MalformedURLException when the {@link getUrl() url} or 
       * {@link #getPath() path} is invalid
       */
      protected abstract HttpUrlMethod getHttpUrlMethod() 
          throws MalformedURLException;
      
      /**
       * Perform the tag functionality. In this case, get the http url method
       * execute it and make it available for validation
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          // allow nested tags first, e.g body
          invokeBody(xmlOutput);
          HttpUrlMethod urlMethod = getConfiguredHttpMethod();
          // track request execution
          long start = System.currentTimeMillis();
          getHttpClient().executeMethod(urlMethod);
          long end = System.currentTimeMillis();
          // set variable to value
          if (getVar() != null) {
              getContext().setVariable(getVar(), urlMethod);
              getContext().setVariable(getVar() + ".responseTime", 
                  String.valueOf(end - start));
          }
      }
  
      /** 
       * retrieve the {@link HttpUrlMethod method} from the subclass and 
       * configure it ready for execution
       *
       * @return a configured {@link HttpUrlMethod method}
       * @throws MalformedURLException when retrieving the URL fails
       */
      private HttpUrlMethod getConfiguredHttpMethod() throws 
      MalformedURLException {
          // retrieve and configure url method
          HttpUrlMethod urlMethod = getHttpUrlMethod();
          urlMethod.setFollowRedirects(isFollowRedirects());
          // add request headers
          NameValuePair header = null;
          for (int index = 0; index < getRequestHeaders().size(); index++) {
              header = (NameValuePair) getRequestHeaders().get(index);
              urlMethod.addRequestHeader(header.getName(), header.getValue());
          }
          // add parameters
          setParameters(urlMethod);
          // add the default user agent to the list if one doesn't exist
          // and the session tag does exist and have a user agent
          if (urlMethod.getRequestHeader(HttpTagSupport.HEADER_NAME_USER_AGENT) 
              == null && getSessionTag() != null
              && getSessionTag().getUserAgent() != null) {
                  
              urlMethod.addRequestHeader(HttpTagSupport.HEADER_NAME_USER_AGENT,
                      getSessionTag().getUserAgent());
          }
          return urlMethod;
      }
      
      /** 
       * Set the current parameters on the url method ready for processing
       *
       * @param method the {@link HttpUrlMethod method} to configure
       * @throws MalformedURLException when {@link #getHttpUrlMethod()} does
       */
      protected void setParameters(HttpUrlMethod method) throws 
      MalformedURLException {
          if (getParameters().size() > 0) {
              NameValuePair[] parameters = (NameValuePair[]) getParameters().
                  toArray(new NameValuePair[0]);
              method.setQueryString(parameters);
          }
      }
      
      /**
       * retrieve the optional parent session tag
       *
       * @return the ancestor tag with class {@link SessionTag} or null if
       *      not found
       */
      private SessionTag getSessionTag() {
          SessionTag sessionTag = (SessionTag) findAncestorWithClass(
              SessionTag.class);
          return sessionTag;
      }
  
      /**
       * return a HttpClient shared on the session tag, or a new one if no
       * session tag exists
       *
       * @return the shared http client from the session tag, or create a new one.
       */
      private HttpMultiClient getHttpClient() {
          SessionTag session = getSessionTag();
          HttpMultiClient client = null;
          if (session != null) {
              client = session.getHttpClient();
              client.setStrictMode(session.isStrictMode());
          } else {
              client = new HttpMultiClient();
          }
          return client;
      }
      
      /**
       * Add a parameter to the list
       *
       * @param name the parameter name
       * @param value the parameter value
       */
      public void addParameter(String name, String value) {
          getParameters().add(new NameValuePair(name, value));
      }
      
      /**
       * Add a request header to the list
       *
       * @param name the header name
       * @param value the header value
       */
      public void addRequestHeader(String name, String value) {
          getRequestHeaders().add(new NameValuePair(name, value));
      }
      
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
      
      /**
       * Getter for property var.
       *
       * @return Value of property var.
       */
      public String getVar() {
          return _var;
      }
      
      /**
       * Setter for property var.
       *
       * @param var New value of property var.
       */
      public void setVar(String var) {
          _var = var;
      }
  
      /** 
       * Getter for property path.
       *
       * @return Value of property path.
       */
      public String getPath() {
          return _path;
      }
      
      /**
       * Setter for property path.
       *
       * @param path New value of property path.
       */
      public void setPath(String path) {
          _path = path;
      }
      
      /**
       * Getter for property uri.
       *
       * @return Value of property uri.
       */
      public String getUri() {
          return _uri;
      }
      
      /**
       * Setter for property uri.
       *
       * @param uri New value of property uri.
       */
      public void setUri(String uri) {
          _uri = uri;
      }
      
      /**
       * Getter for property followRedirects.
       *
       * @return Value of property followRedirects.
       */
      public boolean isFollowRedirects() {
          return _followRedirects;
      }
      
      /**
       * Setter for property followRedirects.
       *
       * @param followRedirects New value of property followRedirects.
       */
      public void setFollowRedirects(boolean followRedirects) {
          _followRedirects = followRedirects;
      }
      
      /**
       * Getter for property parameters.
       *
       * @return Value of property parameters.
       */
      public List getParameters() {
          return _parameters;
      }
      
      /**
       * Setter for property parameters.
       *
       * @param parameters New value of property parameters.
       */
      public void setParameters(List parameters) {
          _parameters = parameters;
      }
      
      /**
       * Getter for property requestHeaders.
       *
       * @return Value of property requestHeaders.
       */
      public List getRequestHeaders() {
          return _requestHeaders;
      }
      
      /** 
       * Setter for property requestHeaders.
       *
       * @param requestHeaders New value of property requestHeaders.
       */
      public void setRequestHeaders(List requestHeaders) {
          _requestHeaders = requestHeaders;
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/BodyTag.java
  
  Index: BodyTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/BodyTag.java,v 1.3 2002/07/14 16:44:10 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 16:44:10 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.http;
  
  import org.apache.commons.httpclient.HttpUrlMethod;
  import org.apache.commons.httpclient.methods.UrlPostMethod;
  import org.apache.commons.httpclient.methods.UrlPutMethod;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /**
   * A tag to set the body for posts and puts etc
   *
   * @author  dion
   * @version $Id: BodyTag.java,v 1.3 2002/07/14 16:44:10 dion Exp $
   */
  public class BodyTag extends TagSupport {
      
      /** Creates a new instance of BodyTag */
      public BodyTag() {
      }
      
      /**
       * Perform the tag functionality. In this case, get the parent http tag,
       * and if it's a post or put, set the request body from the body of this
       * tag.
       *
       * @param xmlOutput for writing output to
       * @throws Exception when any error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          HttpTagSupport httpTag = (HttpTagSupport) findAncestorWithClass(
              HttpTagSupport.class);
          HttpUrlMethod httpMethod = httpTag.getHttpUrlMethod();
          String bodyText = getBodyText();
          if (httpMethod instanceof UrlPostMethod) {
              UrlPostMethod postMethod = (UrlPostMethod) httpMethod;
              postMethod.setRequestBody(bodyText);
          } else if (httpMethod instanceof UrlPutMethod) {
              UrlPutMethod putMethod = (UrlPutMethod) httpMethod;
              putMethod.setRequestBody(bodyText);
          } else {
              throw new IllegalStateException("Http method from parent was "
                  + "not post or put");
          }
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/HeadTag.java
  
  Index: HeadTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/HeadTag.java,v 1.2 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.2 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.http;
  
  import java.net.MalformedURLException;
  
  import org.apache.commons.httpclient.HttpUrlMethod;
  import org.apache.commons.httpclient.methods.UrlHeadMethod;
  
  /**
   * A http get tag
   *
   * @author  dion
   * @version $Id: HeadTag.java,v 1.2 2002/07/14 12:38:22 dion Exp $
   */
  public class HeadTag extends HttpTagSupport {
      
      /** the head method */
      private UrlHeadMethod _headMethod;
      
      /**
       * Creates a new instance of HeadTag
       */
      public HeadTag() {
      }
      
      /**
       * @return a url method for a Head request
       * @throws MalformedURLException when the url is bad
       */
      protected HttpUrlMethod getHttpUrlMethod() throws MalformedURLException {
          if (_headMethod == null) {
              _headMethod = new UrlHeadMethod(getResolvedUrl());
          }
          return _headMethod;
      }
          
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/http/ParameterTag.java
  
  Index: ParameterTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/jelly/ParameterTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   * $Revision: 1.3 $
   * $Date: 2002/07/14 12:38:22 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.jelly.tags.http;
  
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /**
   * A tag to hold parameters
   * 
   * @author  dion
   * @version $Id: ParameterTag.java,v 1.3 2002/07/14 12:38:22 dion Exp $
   */
  public class ParameterTag extends TagSupport {
      /** parameter name */
      private String _name;
      /** parameter value */
      private String _value;
      
      /** Creates a new instance of ParameterTag */
      public ParameterTag() {
      }
  
      /**
       * Perform the tag functionality. In this case, simply evaluate the body.
       *
       * @param xmlOutput where to send output
       * @throws Exception when an error occurs
       */
      public void doTag(XMLOutput xmlOutput) throws Exception {
          HttpTagSupport http = (HttpTagSupport) findAncestorWithClass(
              HttpTagSupport.class);
          http.addParameter(getName(), getValue());
          invokeBody(xmlOutput);
      }
  
      //--------------------------------------------------------------------------
      // Property accessors/mutators
      //--------------------------------------------------------------------------
      /**
       * Getter for property name.
       *
       * @return Value of property name.
       */
      public String getName() {
          return _name;
      }
      
      /**
       * Setter for property name.
       *
       * @param name New value of property name.
       */
      public void setName(String name) {
          _name = name;
      }
      
      /**
       * Getter for property value.
       *
       * @return Value of property value.
       */
      public String getValue() {
          return _value;
      }
      
      /**
       * Setter for property value.
       *
       * @param value New value of property value.
       */
      public void setValue(String value) {
          _value = value;
      }
      
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message