Пример #1
0
  public void refresh() {
    final int maxPosts = 128;
    try {
      for (final Page p : wordpress.getRecentPosts(maxPosts)) {
        final Content postContent =
            pool.addContent(
                new Content() {

                  @Override
                  public String getURL() {
                    return p.getLink();
                  }

                  @Override
                  public String getTitle() {
                    return p.getTitle();
                  }

                  @Override
                  public String getContent() {
                    return p.getDescription();
                  }

                  @Override
                  public Content getParent() {
                    return null;
                  }

                  @Override
                  public void comment(String content) {
                    try {
                      newComment(p.getPostid(), content);
                    } catch (XmlRpcFault ex) {
                      logger.severe("Unable to comment on " + p + ": " + ex.toString());
                    }
                  }
                });
        int numComments = wordpress.getCommentsCount(p.getPostid()).getApproved();
        for (final Comment c : wordpress.getComments("approve", p.getPostid(), numComments, 0)) {
          pool.addContent(
              new Content() {

                @Override
                public String getURL() {
                  return c.getLink();
                }

                @Override
                public String getTitle() {
                  return null;
                }

                @Override
                public String getContent() {
                  return c.getContent();
                }

                @Override
                public Content getParent() {
                  return postContent;
                }

                @Override
                public void comment(String content) {
                  try {
                    newComment(p.getPostid(), content, c.getComment_id());
                  } catch (XmlRpcFault ex) {
                    logger.severe("Unable to comment on " + p + "#" + c + ": " + ex.toString());
                  }
                }
              });
        }
      }
    } catch (XmlRpcFault f) {
      logger.severe(f.toString());
    }
  }
Пример #2
0
 public void newPost(String title, String body) throws XmlRpcFault {
   Page p = new Page();
   p.setTitle(title);
   p.setDescription(body);
   wordpress.newPost(p, true);
 }