Class PostTask

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class PostTask
    extends org.apache.tools.ant.Task
    This task does an http post. Name/value pairs for the post can be set in either or both of two ways, by nested Prop elements and/or by a file containing properties. Nested Prop elements are automatically configured by Ant. Properties from a file are configured by code borrowed from Property so all Ant property constructs (like ${somename}) are resolved prior to the post. This means that a file can be set up in advance of running the build and the appropriate property values will be filled in at run time.
    Version:
    $Revision: 1.11 $
    Author:
    Dale Anson, danson@germane-software.com
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  PostTask.Cookie
      Represents a cookie.
    • Field Summary

      • Fields inherited from class org.apache.tools.ant.Task

        target, taskName, taskType, wrapper
      • Fields inherited from class org.apache.tools.ant.ProjectComponent

        description, location, project
    • Constructor Summary

      Constructors 
      Constructor Description
      PostTask()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addConfiguredProp​(Prop p)
      Adds a name/value pair to post.
      void addText​(java.lang.String text)
      Adds a feature to the Text attribute of the PostTask object
      void execute()
      Do the post.
      void setAppend​(boolean b)
      Should the log file be appended to or overwritten? Default is true, append to the file.
      void setEncoding​(java.lang.String encoding)
      Sets the encoding of the outgoing properties, default is UTF-8.
      void setFailonerror​(boolean fail)
      Should the build fail if the post fails?
      void setFile​(java.io.File f)
      Set the name of a file to read a set of properties from.
      void setLogfile​(java.io.File f)
      Set the name of a file to save the response to.
      void setMaxwait​(int wait)
      How long to wait on the remote server.
      void setProperty​(java.lang.String name)
      Set the name of a property to save the response to.
      void setTo​(java.net.URL name)
      Set the url to post to.
      void setVerbose​(boolean b)
      If true, progress messages and returned data from the post will be displayed.
      void setWantresponse​(boolean b)
      Default is true, get the response from the post.
      • Methods inherited from class org.apache.tools.ant.Task

        bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
      • Methods inherited from class org.apache.tools.ant.ProjectComponent

        clone, getDescription, getLocation, getProject, setDescription, setLocation, setProject
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PostTask

        public PostTask()
    • Method Detail

      • setTo

        public void setTo​(java.net.URL name)
        Set the url to post to. Required.
        Parameters:
        name - the url to post to.
      • setFile

        public void setFile​(java.io.File f)
        Set the name of a file to read a set of properties from.
        Parameters:
        f - the file
      • setLogfile

        public void setLogfile​(java.io.File f)
        Set the name of a file to save the response to. Optional. Ignored if "want response" is false.
        Parameters:
        f - the file
      • setAppend

        public void setAppend​(boolean b)
        Should the log file be appended to or overwritten? Default is true, append to the file.
        Parameters:
        b - append or not
      • setVerbose

        public void setVerbose​(boolean b)
        If true, progress messages and returned data from the post will be displayed. Default is true.
        Parameters:
        b - true = verbose
      • setWantresponse

        public void setWantresponse​(boolean b)
        Default is true, get the response from the post. Can be set to false for "fire and forget" messages.
        Parameters:
        b - print/log server response
      • setProperty

        public void setProperty​(java.lang.String name)
        Set the name of a property to save the response to. Optional. Ignored if "wantResponse" is false.
        Parameters:
        name - the name to use for the property
      • setEncoding

        public void setEncoding​(java.lang.String encoding)
        Sets the encoding of the outgoing properties, default is UTF-8.
        Parameters:
        encoding - The new encoding value
      • setMaxwait

        public void setMaxwait​(int wait)
        How long to wait on the remote server. As a post is generally a two part process (sending and receiving), maxwait is applied separately to each part, that is, if 180 is passed as the wait parameter, this task will spend at most 3 minutes to connect to the remote server and at most another 3 minutes waiting on a response after the post has been sent. This means that the wait period could total as much as 6 minutes (or 360 seconds).

        The default wait period is 3 minutes (180 seconds).

        Parameters:
        wait - time to wait in seconds, set to 0 to wait forever.
      • setFailonerror

        public void setFailonerror​(boolean fail)
        Should the build fail if the post fails?
        Parameters:
        fail - true = fail the build, default is false
      • addConfiguredProp

        public void addConfiguredProp​(Prop p)
                               throws org.apache.tools.ant.BuildException
        Adds a name/value pair to post. Optional.
        Parameters:
        p - A property pair to send as part of the post.
        Throws:
        org.apache.tools.ant.BuildException - When name and/or value are missing.
      • addText

        public void addText​(java.lang.String text)
        Adds a feature to the Text attribute of the PostTask object
        Parameters:
        text - The feature to be added to the Text attribute
      • execute

        public void execute()
                     throws org.apache.tools.ant.BuildException
        Do the post.
        Overrides:
        execute in class org.apache.tools.ant.Task
        Throws:
        org.apache.tools.ant.BuildException - On any error.