Package net.sourceforge.pebble.domain

Examples of net.sourceforge.pebble.domain.BlogService


        entry.addCategory(category);
      }
    }
    entry.setPublished("Publish".equals(status));

    BlogService service = new BlogService();
    service.putBlogEntry(entry);

    line = reader.readLine();
    while (!line.equals("--------")) {
      if (line.equals("COMMENT:")) {
        String commentAuthor = reader.readLine().substring("AUTHOR: ".length());
        String commentEmail = reader.readLine().substring("EMAIL: ".length());
        String commentIpAddress = reader.readLine().substring("IP: ".length());
        String commentUrl = reader.readLine().substring("URL: ".length());
        Date commentDate = sdf.parse(reader.readLine().substring("DATE: ".length()));

        StringBuffer commentBody = new StringBuffer();
        String commentBodyLine = reader.readLine();
        while (!commentBodyLine.equals("-----")) {
          commentBody.append(commentBodyLine);
          commentBodyLine = reader.readLine();
          if (!commentBodyLine.equals("-----")) {
            commentBody.append("<br />");
          }
        }

        Comment comment = entry.createComment(null, commentBody.toString(), commentAuthor, commentEmail, commentUrl, "", commentIpAddress, commentDate, State.APPROVED);
        entry.addComment(comment);
      } else if (line.equals("PING:")) {
        String pingTitle = reader.readLine().substring("TITLE: ".length());
        String pingUrl = reader.readLine().substring("URL: ".length());
        String pingIpAddress = reader.readLine().substring("IP: ".length());
        String pingBlogName = reader.readLine().substring("BLOG NAME: ".length());
        Date pingDate = sdf.parse(reader.readLine().substring("DATE: ".length()));

        StringBuffer pingBody = new StringBuffer();
        String pingBodyLing = reader.readLine();
        while (!pingBodyLing.equals("-----")) {
          pingBody.append(pingBodyLing);
          pingBodyLing = reader.readLine();
          if (!pingBodyLing.equals("-----")) {
            pingBody.append("<br />");
          }
        }

        TrackBack trackBack = entry.createTrackBack(pingTitle, pingBody.toString(), pingUrl, pingBlogName, pingIpAddress, pingDate, State.APPROVED);
        entry.addTrackBack(trackBack);
      }
      line = reader.readLine();
    }

    service.putBlogEntry(entry);

//    System.out.println("--------------------------------------------------");
    System.out.print(".");

    return entry;
View Full Code Here


    BlogEntry entry = new BlogEntry(blog);
    entry.setTitle(title);
    entry.setBody(body);
    entry.setDate(date);

    BlogService service = new BlogService();
    service.putBlogEntry(entry);
  }
View Full Code Here

            } else {
                result.sortByScoreDescending();
            }

            List<SearchHit> hits = result.getHits();
            BlogService service = new BlogService();

            for (SearchHit hit : hits) {
                BlogEntry entry = service.getBlogEntry(hit.getBlog(), hit.getId());
                adaptBlogEntry(entry);
                posts.add(adaptBlogEntry(entry));
            }
            posts.add( searchResultSummary(hits, sortBy, searchString, 0, 0) );
View Full Code Here

            Pageable pageable = new Pageable(hits);
            pageable.setPageSize(pageSize);
            pageable.setPage(offset);
            List<SearchHit> subList = pageable.getListForPage();

            BlogService service = new BlogService();

            for (SearchHit hit : subList ) {
                BlogEntry entry = service.getBlogEntry(hit.getBlog(), hit.getId());
                adaptBlogEntry(entry);
                posts.add(adaptBlogEntry(entry));
            }
            posts.add( searchResultSummary(subList, sortBy, searchString, pageSize, offset) );
View Full Code Here

        "********)");

    Blog blog = getBlogWithPostId(postid);
    postid = getPostId(postid);
    authenticate(blog, username, password);
    BlogService service = new BlogService();
    BlogEntry entry = null;
    try {
      entry = service.getBlogEntry(blog, postid);
    } catch (BlogServiceException e) {
      throw new XmlRpcException(0, "Blog entry with ID of " + postid + " could not be loaded");
    }

    if (entry != null) {
View Full Code Here

      }

      populateEntry(entry, struct, username);
      entry.setPublished(publish);

      BlogService service = new BlogService();
      service.putBlogEntry(entry);

      return formatPostId(blogid, entry.getId());
    } catch (BlogServiceException be) {
      throw new XmlRpcException(0, be.getMessage());
    }
View Full Code Here

    try {
      Blog blog = getBlogWithPostId(postid);
      postid = getPostId(postid);
      authenticate(blog, username, password);
      BlogService service = new BlogService();
      BlogEntry entry = service.getBlogEntry(blog, postid);

      if (entry != null) {
        populateEntry(entry, struct, username);
        entry.setPublished(publish);

        service.putBlogEntry(entry);
      } else {
        throw new XmlRpcException(0, "Blog entry with ID of " + postid + " was not found.");
      }

      return true;
View Full Code Here

    }

    Pageable pageable = new Pageable(responses) {
      public List getListForPage() {
        List responses = new ArrayList();
        BlogService service = new BlogService();
        Iterator it = super.getListForPage().iterator();
        while (it.hasNext()) {
          try {
            responses.add(service.getResponse(blog, (String)it.next()));
          } catch (BlogServiceException e) {
            // do nothing - some responses just won't get shown,
            // but a message will be sent to the blog
          }
        }
View Full Code Here

  }

  public void testFriendlyNamesForBlogEntries() throws Exception {
    BlogEntry be = new BlogEntry(blog);
    be.setTitle("Test blog entry");
    BlogService service = new BlogService();
    service.putBlogEntry(be);
    String permalink = "/" + be.getPermalink().substring(PebbleContext.getInstance().getConfiguration().getUrl().length());
    url = new Request(permalink, blog);
    assertEquals("Blog Entry : Test blog entry", url.getName());
  }
View Full Code Here

  }

  public void testFriendlyNamesForBlogEntriesUsingDefaultPermalinkProvider() throws Exception {
    BlogEntry be = new BlogEntry(blog);
    be.setTitle("Test blog entry");
    BlogService service = new BlogService();
    service.putBlogEntry(be);
    String permalink = "/" + be.getPermalink().substring(PebbleContext.getInstance().getConfiguration().getUrl().length());
    blog.setPermalinkProvider(new TitlePermalinkProvider());
    url = new Request(permalink, blog);
    assertEquals("Blog Entry : Test blog entry", url.getName());
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.pebble.domain.BlogService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.