//# 0 errors, 114 messages
//#
/*
    //#newposttask.java:1:1: class: net.sourceforge.pebble.ant.metaweblog.NewPostTask
    //#newposttask.java:1:1: method: net.sourceforge.pebble.ant.metaweblog.NewPostTask.net.sourceforge.pebble.ant.metaweblog.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.metaweblog;

import java.util.Hashtable;
import java.util.StringTokenizer;
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 MetaWeblog API.
 *
 * @author    Simon Brown
 */
public class NewPostTask extends Task {
    //#newposttask.java:47: method: void net.sourceforge.pebble.ant.metaweblog.NewPostTask.net.sourceforge.pebble.ant.metaweblog.NewPostTask()
    //#newposttask.java:47: Warning: method not available
    //#    -- call on void org.apache.tools.ant.Task()
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.ant.metaweblog.NewPostTask
    //#    method: void net.sourceforge.pebble.ant.metaweblog.NewPostTask()
    //#    unanalyzed callee: void org.apache.tools.ant.Task()
    //#input(void net.sourceforge.pebble.ant.metaweblog.NewPostTask()): this
    //#output(void net.sourceforge.pebble.ant.metaweblog.NewPostTask()): this.handler
    //#post(void net.sourceforge.pebble.ant.metaweblog.NewPostTask()): this.handler == &"metaWeblog"

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

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

    try {
      System.out.println("Calling " + handler + ".newPost at " + url);
    //#newposttask.java:66: method: void net.sourceforge.pebble.ant.metaweblog.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
    //#presumption(void execute()): java.util.StringTokenizer:nextToken(...)@88 != null
    //#test_vector(void execute()): this.category: Addr_Set{null}, Inverse{null}
    //#test_vector(void execute()): java.util.StringTokenizer:hasMoreTokens(...)@87: {1}, {0}
      System.out.println(" blogid=" + blogid);
      System.out.println(" username=" + username);
      System.out.println(" password=********");
      System.out.println(" title=" + title);
      System.out.println(" content=" + content);
      System.out.println(" category=" + category);
      System.out.println(" publish=true");

      XmlRpcClient xmlrpc = new XmlRpcClient(url);
    //#newposttask.java:75: Warning: method not available
    //#    -- call on void org.apache.xmlrpc.XmlRpcClient(String)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.ant.metaweblog.NewPostTask
    //#    method: void execute()
    //#    unanalyzed callee: void org.apache.xmlrpc.XmlRpcClient(String)
      Vector params = new Vector();
      params.add(blogid);
      params.add(username);
      params.add(password);

      Hashtable struct = new Hashtable();
      struct.put("title", title);
      struct.put("description", content);
      Vector categories = new Vector();
      if (category != null) {
        StringTokenizer tok = new StringTokenizer(category, ",");
        while (tok.hasMoreTokens()) {
          categories.add(tok.nextToken().trim());
        }
      }
      struct.put("categories", categories);

      params.add(struct);
      params.add(Boolean.TRUE);
      Object postId = xmlrpc.execute(handler + ".newPost", params);
    //#newposttask.java:95: Warning: method not available
    //#    -- call on Object org.apache.xmlrpc.XmlRpcClient:execute(String, Vector)
    //#    severity: INFORMATIONAL
    //#    class: net.sourceforge.pebble.ant.metaweblog.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:102: end of method: void net.sourceforge.pebble.ant.metaweblog.NewPostTask.execute()

  /**
   * Sets the blog id.
   *
   * @param blogid    a String
   */
  public void setBlogid(String blogid) {
    this.blogid = blogid;
    //#newposttask.java:110: method: void net.sourceforge.pebble.ant.metaweblog.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:111: end of method: void net.sourceforge.pebble.ant.metaweblog.NewPostTask.setBlogid(String)

  /**
   * Sets the XML-RPC username.
   *
   * @param username    a String
   */
  public void setUsername(String username) {
    this.username = username;
    //#newposttask.java:119: method: void net.sourceforge.pebble.ant.metaweblog.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:120: end of method: void net.sourceforge.pebble.ant.metaweblog.NewPostTask.setUsername(String)

  /**
   * Sets the XML-RPC password.
   *
   * @param password    a String
   */
  public void setPassword(String password) {
    this.password = password;
    //#newposttask.java:128: method: void net.sourceforge.pebble.ant.metaweblog.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:129: end of method: void net.sourceforge.pebble.ant.metaweblog.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:137: method: void net.sourceforge.pebble.ant.metaweblog.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:138: end of method: void net.sourceforge.pebble.ant.metaweblog.NewPostTask.setTitle(String)

  /**
   * Sets the blog entry content.
   *
   * @param content   the blog entry content
   */
  public void setContent(String content) {
    this.content = content;
    //#newposttask.java:146: method: void net.sourceforge.pebble.ant.metaweblog.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:147: end of method: void net.sourceforge.pebble.ant.metaweblog.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:155: method: void net.sourceforge.pebble.ant.metaweblog.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:156: end of method: void net.sourceforge.pebble.ant.metaweblog.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:164: method: void net.sourceforge.pebble.ant.metaweblog.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:165: end of method: void net.sourceforge.pebble.ant.metaweblog.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:173: method: void net.sourceforge.pebble.ant.metaweblog.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:174: end of method: void net.sourceforge.pebble.ant.metaweblog.NewPostTask.setHandler(String)

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