Examples of BoardSettings


Examples of net.easymodo.asagi.settings.BoardSettings

    public static BufferedWriter getDebugOut() {
        return debugOut;
    }

    private static BoardSettings getBoardSettings(Settings settings, String boardName) {
        BoardSettings defaults = settings.getBoardSettings().get("default");
        BoardSettings bSet = settings.getBoardSettings().get(boardName);

        bSet.initSetting("path", defaults.getPath() + "/" + boardName + "/");
        bSet.initSetting("table", boardName);

        // set everything that isn't set already to their defaults
        bSet.initSettings(defaults);

        return bSet;
    }
View Full Code Here

Examples of net.easymodo.asagi.settings.BoardSettings

        return bSet;
    }

    private static void spawnBoard(String boardName, Settings settings) throws BoardInitException {
        BoardSettings bSet = getBoardSettings(settings, boardName);

        int pageLimbo = bSet.getDeletedThreadsThresholdPage();
        boolean fullThumb = (bSet.getThumbThreads() != 0);
        boolean fullMedia = (bSet.getMediaThreads() != 0);

        // Init source board engine through reflection
        Board sourceBoard;
        try {
            Class<?> sourceBoardClass = Class.forName("net.easymodo.asagi." + sourceEngine);
            sourceBoard = (Board) sourceBoardClass.getConstructor(String.class, BoardSettings.class).newInstance(boardName, bSet);
        } catch(ClassNotFoundException e) {
            throw new BoardInitException("Error initializing board engine " + sourceEngine + ", no such engine?");
        } catch(Exception e) {
            throw new BoardInitException("Error initializing board engine " + sourceEngine);
        }

        // Same for DB engine
        String boardEngine = bSet.getEngine() == null ? "Mysql" : bSet.getEngine();
        bSet.setEngine(boardEngine);

        Class<?> sqlBoardClass;
        Constructor<?> boardCnst;

        // Init two DB objects: one for topic insertion and another
        // for media insertion
        Object topicDbObj;
        Object mediaDbObj;

        try {
            sqlBoardClass = Class.forName("net.easymodo.asagi." + boardEngine);
            boardCnst = sqlBoardClass.getConstructor(String.class, BoardSettings.class);

            // For topics
            topicDbObj = boardCnst.newInstance(bSet.getPath(), bSet);

            // For media
            mediaDbObj = boardCnst.newInstance(bSet.getPath(), bSet);
        } catch(ClassNotFoundException e) {
            throw new BoardInitException("Could not find board engine for " + boardEngine);
        } catch(NoSuchMethodException e) {
            throw new BoardInitException("Error initializing board engine " + boardEngine);
        } catch(InstantiationException e) {
            throw new BoardInitException("Error initializing board engine " + boardEngine);
        } catch(IllegalAccessException e) {
            throw new BoardInitException("Error initializing board engine " + boardEngine);
        } catch(InvocationTargetException e) {
            if(e.getCause() instanceof BoardInitException)
                throw (BoardInitException)e.getCause();
            else if(e.getCause() instanceof RuntimeException)
                throw (RuntimeException)e.getCause();
            throw new BoardInitException("Error initializing board engine " + boardEngine);
        }

        // Making sure we got valid DB engines for post and media insertion
        DB topicDb = null;
        DB mediaDb = null;

        if(topicDbObj instanceof DB && mediaDbObj instanceof DB) {
            topicDb = (DB) topicDbObj;
            mediaDb = (DB) mediaDbObj;
        }

        if(topicDb == null) {
            throw new BoardInitException("Wrong engine specified for " + boardEngine);
        }

        Local topicLocalBoard = new Local(bSet.getPath(), bSet, topicDb);
        Local mediaLocalBoard = new Local(bSet.getPath(), bSet, mediaDb);

        // And the dumper, le sigh.
        AbstractDumper dumper;
        try {
            Class<?> dumperClass = Class.forName("net.easymodo.asagi." + dumperEngine);
View Full Code Here
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.