2 * jSite2 - InsertManager.java - Copyright © 2008 David Roden
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License as published by the Free Software
6 * Foundation; either version 2 of the License, or (at your option) any later
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
16 * Place - Suite 330, Boston, MA 02111-1307, USA.
19 package net.pterodactylus.jsite.core;
21 import java.util.HashMap;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
26 import net.pterodactylus.util.logging.Logging;
29 * Manages all currently running and past inserts.
31 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
33 public class InsertManager {
36 private static final Logger logger = Logging.getLogger(InsertManager.class.getName());
38 /** The insert listener support. */
39 private final InsertListenerSupport insertListenerSupport = new InsertListenerSupport();
41 /** Mapping from insert IDs to inserts. */
42 private final Map<String, Insert> inserts = new HashMap<String, Insert>();
49 * Adds an insert listener to the list of insert listeners.
51 * @param insertListener
52 * The insert listener to add
54 public void addInsertListener(InsertListener insertListener) {
55 logger.log(Level.FINEST, "addInsertListener(insertListener=" + insertListener + ")");
56 insertListenerSupport.addListener(insertListener);
60 * Removes an insert listener from the list of insert listeners.
62 * @param insertListener
63 * The insert listener to remove
65 public void removeInsertListener(InsertListener insertListener) {
66 logger.log(Level.FINEST, "removeInsertListener(insertListener=" + insertListener + ")");
67 insertListenerSupport.removeListener(insertListener);
75 * Starts to insert the given project. The insert will be made to the node
76 * stored in the project, and if no node is specified in the project, the
77 * given node will be used.
80 * The project to insert
82 * The node to insert the project to if the project does not
85 public void insertProject(Project project, Node node) {
86 logger.log(Level.FINEST, "insertProject(project=" + project + ",node=" + node + ")");
87 Node insertNode = project.getNode();
88 if (insertNode == null) {
90 if (insertNode == null) {
91 throw new NullPointerException("node must not be null");
94 String insertId = "insert-" + project.getId();
95 Insert newInsert = new Insert(project, insertNode, insertId);
96 inserts.put(insertId, newInsert);
98 insertListenerSupport.fireInsertAdded(newInsert);
99 /* TODO - start insert */
103 * Starts the insert manager.
105 public void start() {
106 logger.log(Level.FINEST, "start()");
115 * Loads the configuration.
117 private void loadConfiguration() {
118 logger.log(Level.FINEST, "loadConfiguration()");
122 * Saves the configuration.
124 private void saveConfiguration() {
125 logger.log(Level.FINEST, "saveConfiguration()");