//# 0 errors, 115 messages
//#
/*
    //#newposttask.java:1:1: class: net.sourceforge.pebble.ant.blogger.NewPostTask
    //#newposttask.java:1:1: method: net.sourceforge.pebble.ant.blogger.NewPostTask.net.sourceforge.pebble.ant.blogger.NewPostTask__static_init
 * Copyright (c) 2003-2005, Simon Brown
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   - Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *
 *   - 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.
 *
 *   - Neither the name of Pebble nor the names of its contributors may
 *     be used to endorse or promote products derived from this software
 *     without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS 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 COPYRIGHT OWNER OR 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.
 */
package net.sourceforge.pebble.ant.blogger;

import java.util.Vector;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.xmlrpc.XmlRpcClient;

/**
 * Ant task to post to a blog via the Blogger API.
 *
 * @author    Simon Brown
 */
public class NewPostTask extends Task {
    //#newposttask.java:45: method: void net.sourceforge.pebble.ant.blogger.NewPostTask.net.sourceforge.pebble.ant.blogger.NewPostTask()
    //#newposttask.java:45: Warning: method not available
    //#    -- call on void org.apache.tools.ant.Task()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.ant.blogger.NewPostTask
    //#    method: void net.sourceforge.pebble.ant.blogger.NewPostTask()
    //#    unanalyzed callee: void org.apache.tools.ant.Task()
    //#input(void net.sourceforge.pebble.ant.blogger.NewPostTask()): this
    //#output(void net.sourceforge.pebble.ant.blogger.NewPostTask()): this.handler
    //#post(void net.sourceforge.pebble.ant.blogger.NewPostTask()): this.handler == &"blogger"

  private static final String APP_KEY = "Pebble Blogger API Ant Task";

  private String blogid;
  private String username;
  private String password;
  private String title;
  private String content;
  private String category;
  private String url;
  private String handler = "blogger";
    //#newposttask.java:56: end of method: void net.sourceforge.pebble.ant.blogger.NewPostTask.net.sourceforge.pebble.ant.blogger.NewPostTask()

  /**
   * Performs the work of this task.
   *
   * @throws BuildException   if something goes wrong
   */
  public void execute() throws BuildException {

    // create the content
    //  - a <title> tag containing the title
    //  - a <category> tag containing a comma separated list of categories
    //  - the blog entry content
    StringBuffer buf = new StringBuffer();
    //#newposttask.java:69: method: void net.sourceforge.pebble.ant.blogger.NewPostTask.execute()
    //#input(void execute()): java.lang.Boolean.TRUE
    //#input(void execute()): java.lang.System.out
    //#input(void execute()): this
    //#input(void execute()): this.blogid
    //#input(void execute()): this.category
    //#input(void execute()): this.content
    //#input(void execute()): this.handler
    //#input(void execute()): this.password
    //#input(void execute()): this.title
    //#input(void execute()): this.url
    //#input(void execute()): this.username
    //#pre[2] (void execute()): init'ed(this.blogid)
    //#pre[3] (void execute()): init'ed(this.category)
    //#pre[4] (void execute()): init'ed(this.content)
    //#pre[5] (void execute()): init'ed(this.handler)
    //#pre[6] (void execute()): init'ed(this.password)
    //#pre[7] (void execute()): init'ed(this.title)
    //#pre[8] (void execute()): init'ed(this.url)
    //#pre[9] (void execute()): init'ed(this.username)
    //#presumption(void execute()): init'ed(java.lang.Boolean.TRUE)
    //#presumption(void execute()): java.lang.System.out != null
    //#test_vector(void execute()): this.category: Addr_Set{null}, Inverse{null}
    //#test_vector(void execute()): this.title: Addr_Set{null}, Inverse{null}
    //#test_vector(void execute()): java.lang.String:length(...)@70: {0}, {1..4_294_967_295}
    //#test_vector(void execute()): java.lang.String:length(...)@75: {0}, {1..4_294_967_295}
    if (title != null && title.length() > 0) {
      buf.append("<title>");
      buf.append(title);
      buf.append("</title>");
    }
    if (category != null && category.length() > 0) {
      buf.append("<category>");
      buf.append(category);
      buf.append("</category>");
    }
    buf.append(content);

    try {
      System.out.println("Calling " + handler + ".newPost at " + url);
      System.out.println(" appkey=" + APP_KEY);
      System.out.println(" blogid=" + blogid);
      System.out.println(" username=" + username);
      System.out.println(" password=********");
      System.out.println(" content=" + buf.toString());
      System.out.println(" publish=true");

      XmlRpcClient xmlrpc = new XmlRpcClient(url);
    //#newposttask.java:91: Warning: method not available
    //#    -- call on void org.apache.xmlrpc.XmlRpcClient(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.ant.blogger.NewPostTask
    //#    method: void execute()
    //#    unanalyzed callee: void org.apache.xmlrpc.XmlRpcClient(String)
      Vector params = new Vector();
      params.add(APP_KEY);
      params.add(blogid);
      params.add(username);
      params.add(password);
      params.add(buf.toString());
      params.add(Boolean.TRUE);
      Object postId = xmlrpc.execute(handler + ".newPost", params);
    //#newposttask.java:99: Warning: method not available
    //#    -- call on Object org.apache.xmlrpc.XmlRpcClient:execute(String, Vector)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.ant.blogger.NewPostTask
    //#    method: void execute()
    //#    unanalyzed callee: Object org.apache.xmlrpc.XmlRpcClient:execute(String, Vector)

      System.out.println("New post id is " + postId);

    } catch (Exception e) {
      throw new BuildException(e);
    }
  }
    //#newposttask.java:106: end of method: void net.sourceforge.pebble.ant.blogger.NewPostTask.execute()

  /**
   * Sets the blog id.
   *
   * @param blogid    a String
   */
  public void setBlogid(String blogid) {
    this.blogid = blogid;
    //#newposttask.java:114: method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setBlogid(String)
    //#input(void setBlogid(String)): blogid
    //#input(void setBlogid(String)): this
    //#output(void setBlogid(String)): this.blogid
    //#post(void setBlogid(String)): this.blogid == blogid
    //#post(void setBlogid(String)): init'ed(this.blogid)
  }
    //#newposttask.java:115: end of method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setBlogid(String)

  /**
   * Sets the XML-RPC username.
   *
   * @param username    a String
   */
  public void setUsername(String username) {
    this.username = username;
    //#newposttask.java:123: method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setUsername(String)
    //#input(void setUsername(String)): this
    //#input(void setUsername(String)): username
    //#output(void setUsername(String)): this.username
    //#post(void setUsername(String)): this.username == username
    //#post(void setUsername(String)): init'ed(this.username)
  }
    //#newposttask.java:124: end of method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setUsername(String)

  /**
   * Sets the XML-RPC password.
   *
   * @param password    a String
   */
  public void setPassword(String password) {
    this.password = password;
    //#newposttask.java:132: method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setPassword(String)
    //#input(void setPassword(String)): password
    //#input(void setPassword(String)): this
    //#output(void setPassword(String)): this.password
    //#post(void setPassword(String)): this.password == password
    //#post(void setPassword(String)): init'ed(this.password)
  }
    //#newposttask.java:133: end of method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setPassword(String)

  /**
   * Sets the title of the blog entry.
   *
   * @param title   the blog entry title
   */
  public void setTitle(String title) {
    this.title = title;
    //#newposttask.java:141: method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setTitle(String)
    //#input(void setTitle(String)): this
    //#input(void setTitle(String)): title
    //#output(void setTitle(String)): this.title
    //#post(void setTitle(String)): this.title == title
    //#post(void setTitle(String)): init'ed(this.title)
  }
    //#newposttask.java:142: end of method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setTitle(String)

  /**
   * Sets the blog entry content.
   *
   * @param content   the blog entry content
   */
  public void setContent(String content) {
    this.content = content;
    //#newposttask.java:150: method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setContent(String)
    //#input(void setContent(String)): content
    //#input(void setContent(String)): this
    //#output(void setContent(String)): this.content
    //#post(void setContent(String)): this.content == content
    //#post(void setContent(String)): init'ed(this.content)
  }
    //#newposttask.java:151: end of method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setContent(String)

  /**
   * Sets the category to which the blog entry should be added to.
   *
   * @param category    the category ID as a String
   */
  public void setCategory(String category) {
    this.category = category;
    //#newposttask.java:159: method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setCategory(String)
    //#input(void setCategory(String)): category
    //#input(void setCategory(String)): this
    //#output(void setCategory(String)): this.category
    //#post(void setCategory(String)): this.category == category
    //#post(void setCategory(String)): init'ed(this.category)
  }
    //#newposttask.java:160: end of method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setCategory(String)

  /**
   * Sets the URL of the XML-RPC call.
   *
   * @param url   the URL as a String
   */
  public void setUrl(String url) {
    this.url = url;
    //#newposttask.java:168: method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setUrl(String)
    //#input(void setUrl(String)): this
    //#input(void setUrl(String)): url
    //#output(void setUrl(String)): this.url
    //#post(void setUrl(String)): this.url == url
    //#post(void setUrl(String)): init'ed(this.url)
  }
    //#newposttask.java:169: end of method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setUrl(String)

  /**
   * Sets the name of the XML-RPC Blogger API handler (e.g. "blogger").
   *
   * @param handler   the name of the handler as a String
   */
  public void setHandler(String handler) {
    this.handler = handler;
    //#newposttask.java:177: method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setHandler(String)
    //#input(void setHandler(String)): handler
    //#input(void setHandler(String)): this
    //#output(void setHandler(String)): this.handler
    //#post(void setHandler(String)): this.handler == handler
    //#post(void setHandler(String)): init'ed(this.handler)
  }
    //#newposttask.java:178: end of method: void net.sourceforge.pebble.ant.blogger.NewPostTask.setHandler(String)

}
    //#output(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Descendant_Table[net/sourceforge/pebble/ant/blogger/NewPostTask]
    //#output(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.execute()V
    //#output(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setBlogid(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setCategory(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setContent(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setHandler(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setPassword(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setTitle(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setUrl(Ljava/lang/String;)V
    //#output(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setUsername(Ljava/lang/String;)V
    //#post(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Descendant_Table[net/sourceforge/pebble/ant/blogger/NewPostTask] == &__Dispatch_Table
    //#post(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.execute()V == &execute
    //#post(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setBlogid(Ljava/lang/String;)V == &setBlogid
    //#post(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setCategory(Ljava/lang/String;)V == &setCategory
    //#post(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setContent(Ljava/lang/String;)V == &setContent
    //#post(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setHandler(Ljava/lang/String;)V == &setHandler
    //#post(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setPassword(Ljava/lang/String;)V == &setPassword
    //#post(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setTitle(Ljava/lang/String;)V == &setTitle
    //#post(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setUrl(Ljava/lang/String;)V == &setUrl
    //#post(net.sourceforge.pebble.ant.blogger.NewPostTask__static_init): __Dispatch_Table.setUsername(Ljava/lang/String;)V == &setUsername
    //#newposttask.java:: end of method: net.sourceforge.pebble.ant.blogger.NewPostTask.net.sourceforge.pebble.ant.blogger.NewPostTask__static_init
    //#newposttask.java:: end of class: net.sourceforge.pebble.ant.blogger.NewPostTask
