/**
   * Get a particular post for a blojsom category
   *
   * @since blojsom 1.9.3
   * @param appkey Unique identifier/passcode of the application sending the post
   * @param blogid Unique identifier of the blog the post will be added to
   * @param userid Login for a Blogger user who has permission to post to the blog
   * @param password Password for said username
   * @throws XmlRpcException If the user was not authenticated correctly
   * @return Post to the blog
   */
  public Object getPost(String appkey, String blogid, String userid, String password)
      throws Exception {
    _logger.debug("getPost() Called ===========[ SUPPORTED ]=====");
    _logger.debug("     Appkey: " + appkey);
    _logger.debug("     BlogId: " + blogid);
    _logger.debug("     UserId: " + userid);
    _logger.debug("   Password: "******"?" + PERMALINK_PARAM + "=";

      int pos = blogid.indexOf(match);
      if (pos != -1) {
        category = blogid.substring(0, pos);
        category = BlojsomUtils.normalize(category);
        permalink = blogid.substring(pos + match.length());

        Map fetchMap = new HashMap();
        BlogCategory blogCategory = _fetcher.newBlogCategory();
        blogCategory.setCategory(category);
        blogCategory.setCategoryURL(_blog.getBlogURL() + category);
        fetchMap.put(BlojsomFetcher.FETCHER_CATEGORY, blogCategory);
        fetchMap.put(BlojsomFetcher.FETCHER_PERMALINK, permalink);
        BlogEntry[] _entries = _fetcher.fetchEntries(fetchMap, _blogUser);

        if (_entries != null && _entries.length > 0) {
          BlogEntry entry = _entries[0];
          Hashtable entrystruct = new Hashtable();
          entrystruct.put(MEMBER_POSTID, entry.getId());
          entrystruct.put(MEMBER_BLOGID, entry.getCategory());
          entrystruct.put(MEMBER_TITLE, entry.getEscapedTitle());
          entrystruct.put(MEMBER_URL, entry.getEscapedLink());
          entrystruct.put(MEMBER_CONTENT, entry.getTitle() + "\n" + entry.getDescription());
          entrystruct.put(MEMBER_DATECREATED, entry.getDate());
          entrystruct.put(MEMBER_AUTHORNAME, _blog.getBlogOwner());
          entrystruct.put(MEMBER_AUTHOREMAIL, _blog.getBlogOwnerEmail());

          return entrystruct;
        } else {
          throw new XmlRpcException(INVALID_POSTID, INVALID_POSTID_MSG);
        }
      } else {
        throw new XmlRpcException(INVALID_POSTID, INVALID_POSTID_MSG);
      }
    } catch (BlojsomException e) {
      _logger.error(
          "Failed to authenticate user [" + userid + "] with password [" + password + "]");
      throw new XmlRpcException(AUTHORIZATION_EXCEPTION, AUTHORIZATION_EXCEPTION_MSG);
    }
  }
  /**
   * Process the blog entries
   *
   * @param httpServletRequest Request
   * @param httpServletResponse Response
   * @param user {@link BlogUser} instance
   * @param context Context
   * @param entries Blog entries retrieved for the particular request
   * @return Modified set of blog entries
   * @throws BlojsomPluginException If there is an error processing the blog entries
   */
  public BlogEntry[] process(
      HttpServletRequest httpServletRequest,
      HttpServletResponse httpServletResponse,
      BlogUser user,
      Map context,
      BlogEntry[] entries)
      throws BlojsomPluginException {
    Blog blog = user.getBlog();

    // If there are no entries return
    if (entries.length <= 0) {
      return entries;
    } else {
      // Pull the latest entry, check its date to see if its newer than the lastPingDate, and
      // if so, ping weblogs.com
      BlogEntry entry = entries[0];
      if (_lastPingDate.before(entry.getDate())) {
        synchronized (_lastPingDate) {
          _lastPingDate = entry.getDate();
        }

        try {
          XmlRpcClient client = new XmlRpcClient(DEFAULT_WEBLOGS_URL);
          Vector params = new Vector();
          params.add(blog.getBlogName());
          params.add(blog.getBlogURL());
          client.executeAsync(WEBLOGS_PING_METHOD, params, _callbackHandler);
        } catch (IOException e) {
          _logger.error(e);
        }
      } else {
        _logger.debug("Latest entry date occurs before latest ping date.");
      }
    }

    return entries;
  }
  /**
   * Get a list of recent posts for a blojsom category
   *
   * @param appkey Unique identifier/passcode of the application sending the post
   * @param blogid Unique identifier of the blog the post will be added to
   * @param userid Login for a Blogger user who has permission to post to the blog
   * @param password Password for said username
   * @param numposts Number of Posts to Retrieve
   * @throws XmlRpcException If the user was not authenticated correctly
   * @return Recent posts to the blog
   */
  public Object getRecentPosts(
      String appkey, String blogid, String userid, String password, int numposts) throws Exception {
    _logger.debug("getRecentPosts() Called ===========[ SUPPORTED ]=====");
    _logger.debug("     Appkey: " + appkey);
    _logger.debug("     BlogId: " + blogid);
    _logger.debug("     UserId: " + userid);
    _logger.debug("   Password: "******"     Number: " + numposts);

    Vector recentPosts = new Vector();
    blogid = BlojsomUtils.normalize(blogid);

    try {
      _authorizationProvider.loadAuthenticationCredentials(_blogUser);
      _authorizationProvider.authorize(_blogUser, null, userid, password);

      // Quick verify that the categories are valid
      File blogCategoryFile =
          new File(_blog.getBlogHome() + BlojsomUtils.removeInitialSlash(blogid));
      if (blogCategoryFile.exists() && blogCategoryFile.isDirectory()) {

        String requestedCategory = BlojsomUtils.removeInitialSlash(blogid);
        BlogCategory blogCategory = _fetcher.newBlogCategory();
        blogCategory.setCategory(blogid);
        blogCategory.setCategoryURL(_blog.getBlogURL() + requestedCategory);

        BlogEntry[] entries;
        Map fetchMap = new HashMap();

        if (BlojsomUtils.checkNullOrBlank(requestedCategory)) {
          fetchMap.put(BlojsomFetcher.FETCHER_FLAVOR, DEFAULT_FLAVOR_HTML);
          fetchMap.put(BlojsomFetcher.FETCHER_NUM_POSTS_INTEGER, new Integer(numposts));
          entries = _fetcher.fetchEntries(fetchMap, _blogUser);
        } else {
          fetchMap.put(BlojsomFetcher.FETCHER_CATEGORY, blogCategory);
          fetchMap.put(BlojsomFetcher.FETCHER_NUM_POSTS_INTEGER, new Integer(numposts));
          entries = _fetcher.fetchEntries(fetchMap, _blogUser);
        }

        if (entries != null && entries.length > 0) {
          for (int x = 0; x < entries.length; x++) {
            BlogEntry entry = entries[x];
            Hashtable entrystruct = new Hashtable();
            entrystruct.put(MEMBER_POSTID, entry.getId());
            entrystruct.put(MEMBER_BLOGID, entry.getCategory());
            entrystruct.put(MEMBER_TITLE, entry.getEscapedTitle());
            entrystruct.put(MEMBER_URL, entry.getEscapedLink());
            entrystruct.put(MEMBER_CONTENT, entry.getTitle() + "\n" + entry.getDescription());
            entrystruct.put(MEMBER_DATECREATED, entry.getDate());
            entrystruct.put(MEMBER_AUTHORNAME, _blog.getBlogOwner());
            entrystruct.put(MEMBER_AUTHOREMAIL, _blog.getBlogOwnerEmail());
            recentPosts.add(entrystruct);
          }
        }
      }

      return recentPosts;
    } catch (BlojsomException e) {
      _logger.error(
          "Failed to authenticate user [" + userid + "] with password [" + password + "]");
      throw new XmlRpcException(AUTHORIZATION_EXCEPTION, AUTHORIZATION_EXCEPTION_MSG);
    }
  }