Package org.mapache.business.blog

Source Code of org.mapache.business.blog.BlogManager

package org.mapache.business.blog;

import java.util.ArrayList;
import java.util.Collection;

import java.util.List;

import org.mapache.business.MapacheException;
import org.mapache.business.category.Category;
import org.mapache.business.category.CategoryManager;
import org.mapache.business.configuration.ConfigurationManager;
import org.mapache.business.reply.Reply;
import org.mapache.business.reply.ReplyManager;
import org.mapache.business.topic.Topic;
import org.mapache.business.topic.TopicManager;
import org.mapache.business.user.User;
import org.mapache.business.user.UserManager;
import org.mapache.data.BlogDAO;
import org.mapache.data.DAOException;
import org.mapache.data.DAOFactory;
import org.mapache.data.UserDAO;
import org.mapache.data.mysql.MySQLDAOFactory;

public class BlogManager {
    private ReplyManager replyManager;
    private TopicManager topicManager;
    private CategoryManager categoryManager;
    private ConfigurationManager configurationManager;
    private BlogDAO blogDataAccess;
    private static BlogManager instance;

    public BlogManager() {
        blogDataAccess =
                configurationManager.getInstance().getDAOFactory().getBlogDAO();
        categoryManager = new CategoryManager();
        topicManager = new TopicManager();
        replyManager = new ReplyManager();
    }

    public static BlogManager getInstance() {
        if (instance == null)
            instance = new BlogManager();
        return instance;
    }
    public List<Blog> loadAllBlogs() throws MapacheException {
        return blogDataAccess.loadAllBlogs();
    }

    public void saveBlog(Blog _blog) throws MapacheException {
        blogDataAccess.saveBlog(_blog);
    }
    public void deleteBlog(Blog blog) throws MapacheException {
        if(blog.getTopicCount()>0){
            throw new MapacheException("Blog contains topics, can't delete blog",null);
        }
        else{
            blogDataAccess.deleteBlog(blog);
        }
    }
    public void createBlog(Blog blog) throws MapacheException {
        blogDataAccess.createBlog(blog);
    }
    public Blog loadBlogByBlogID(int blogID) throws MapacheException {
        return blogDataAccess.loadBlogByBlogID(blogID);
    }


    public List<Blog> loadAllBlogs_visitor() throws MapacheException {
        return blogDataAccess.loadAllBlogs_visitor();
    }

    public Blog loadBlogByBlogName_visitor(String string) throws MapacheException{
        return blogDataAccess.loadBlogByBlogName_visitor(string);
    }
}
TOP

Related Classes of org.mapache.business.blog.BlogManager

TOP
Copyright © 2018 www.massapi.com. 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.