Package net.sourceforge.pebble.dao

Examples of net.sourceforge.pebble.dao.BlogEntryDAO


    blogEntry = cache.getBlogEntry(blog, blogEntryId);
    if (blogEntry != null) {
      log.debug("Got blog entry " + blogEntryId + " from cache");
    } else {
      log.debug("Loading blog entry " + blogEntryId + " from disk");
      BlogEntryDAO dao = DAOFactory.getConfiguredFactory().getBlogEntryDAO();
      try {
        blogEntry = dao.loadBlogEntry(blog, blogEntryId);

        if (blogEntry != null) {
          // place in the cache for faster lookup next time
          cache.putBlogEntry(blogEntry);
        }
View Full Code Here


   * Gets all blog entries for the specified blog.
   *
   * @return  a List of BlogEntry objects
   */
  public Collection<BlogEntry> getBlogEntries(Blog blog) throws BlogServiceException {
    BlogEntryDAO dao = DAOFactory.getConfiguredFactory().getBlogEntryDAO();
    Collection<BlogEntry> blogEntries;
    try {
      blogEntries = dao.loadBlogEntries(blog);
      for (BlogEntry blogEntry : blogEntries) {
        blogEntry.setPersistent(true);
      }

    } catch (PersistenceException pe) {
View Full Code Here

  /**
   * Puts the blog entry with the specified id.
   */
  public void putBlogEntry(BlogEntry blogEntry) throws BlogServiceException {
    DAOFactory factory = DAOFactory.getConfiguredFactory();
    BlogEntryDAO dao = factory.getBlogEntryDAO();
    Blog blog = blogEntry.getBlog();
    ContentCache cache = ContentCache.getInstance();

    synchronized (blog) {
      try {
        BlogEntry be = getBlogEntry(blog, blogEntry.getId());

        if (!blogEntry.isPersistent() && be != null) {
          // the blog entry is new but one exists with the same ID already
          // - increment the date/ID and try again
          blogEntry.setDate(new Date(blogEntry.getDate().getTime() + 1));
          putBlogEntry(blogEntry);
        } else {
          if (!blogEntry.isPersistent()) {
            dao.storeBlogEntry(blogEntry);
            blogEntry.insertEvent(new BlogEntryEvent(blogEntry, BlogEntryEvent.BLOG_ENTRY_ADDED));

            for (Comment comment : blogEntry.getComments()) {
              blogEntry.addEvent(new CommentEvent(comment, CommentEvent.COMMENT_ADDED));
            }
            for (TrackBack trackBack : blogEntry.getTrackBacks()) {
              blogEntry.addEvent(new TrackBackEvent(trackBack, TrackBackEvent.TRACKBACK_ADDED));
            }
          } else {
            dao.storeBlogEntry(blogEntry);
            if (blogEntry.isDirty()) {
              blogEntry.insertEvent(new BlogEntryEvent(blogEntry, blogEntry.getPropertyChangeEvents()));
            }
          }

          blogEntry.getBlog().getEventDispatcher().fireEvents(blogEntry);

          // and store the blog entry now that listeners have been fired
          dao.storeBlogEntry(blogEntry);
          cache.removeBlogEntry(blogEntry);
        }

        blogEntry.setPersistent(true);
      } catch (PersistenceException pe) {
View Full Code Here

    Blog blog = blogEntry.getBlog();
    ContentCache cache = ContentCache.getInstance();

    try {
      DAOFactory factory = DAOFactory.getConfiguredFactory();
      BlogEntryDAO dao = factory.getBlogEntryDAO();
      dao.removeBlogEntry(blogEntry);
      blogEntry.setPersistent(false);

      // remove from cache
      cache.removeBlogEntry(blogEntry);
View Full Code Here

TOP

Related Classes of net.sourceforge.pebble.dao.BlogEntryDAO

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.