456ddaeac220fb626971ad62fbdec2eb42af5e34
[jSite2.git] / src / net / pterodactylus / jsite / core / Core.java
1 /*
2  * jSite2 - Core.java -
3  * Copyright © 2008 David Roden
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19
20 package net.pterodactylus.jsite.core;
21
22 import java.io.IOException;
23 import java.net.UnknownHostException;
24 import java.util.List;
25
26 import net.pterodactylus.jsite.project.Project;
27
28 /**
29  * Interface for the core.
30  * 
31  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
32  */
33 public interface Core {
34
35         /**
36          * Adds the given listener to the list of registered listeners.
37          * 
38          * @param coreListener
39          *            The listener to add
40          */
41         public void addCoreListener(CoreListener coreListener);
42
43         /**
44          * Removes the given listener from the list of registered listeners.
45          * 
46          * @param coreListener
47          *            The listener to remove
48          */
49         public void removeCoreListener(CoreListener coreListener);
50
51         /**
52          * Adds the given node to the core.
53          * 
54          * @param node
55          *            The node to add
56          * @return <code>true</code> if the node was added, <code>false</code>
57          *         if it was not added because it was already known
58          * @throws UnknownHostException
59          *             if the hostname of the node can not be resolved
60          */
61         public boolean addNode(Node node) throws UnknownHostException;
62
63         /**
64          * Removes the given node from the core.
65          * 
66          * @param node
67          *            The node to remove
68          */
69         public void removeNode(Node node);
70
71         /**
72          * Returns the list of all configured nodes.
73          * 
74          * @return All configured nodes
75          */
76         public List<Node> getNodes();
77
78         /**
79          * Returns whether the core is currently connected to the given node.
80          * 
81          * @param node
82          *            The node to check
83          * @return <code>true</code> if the core is currently connected to the
84          *         node, <code>false</code> otherwise
85          */
86         public boolean isNodeConnected(Node node);
87
88         /**
89          * Starts the core.
90          */
91         public void start();
92
93         /**
94          * Stops the core.
95          */
96         public void stop();
97
98         /**
99          * Connects to the given node.
100          * 
101          * @param node
102          *            The node to connect to
103          */
104         public void connectToNode(Node node);
105
106         /**
107          * Disconnects from the given node.
108          * 
109          * @param node
110          *            The node to disconnect from
111          */
112         public void disconnectFromNode(Node node);
113
114         /**
115          * Creates a new project.
116          * 
117          * @throws IOException
118          *             if an I/O error occured communicating with the node
119          * @throws JSiteException
120          *             if there is a problem with the node
121          */
122         public void createProject() throws IOException, JSiteException;
123
124         /**
125          * Clones the given project. {@link CoreListener}s will be notified of the
126          * new clone via the {@link CoreListener#projectCloned(Project, Project)}
127          * event.
128          * 
129          * @param project
130          *            The project to clone
131          */
132         public void cloneProject(Project project);
133
134         /**
135          * Removes the given project.
136          * 
137          * @param project
138          *            The project to remove
139          */
140         public void removeProject(Project project);
141
142         /**
143          * Returns a list of all projects.
144          * 
145          * @return A list of all projects
146          */
147         public List<Project> getProjects();
148
149 }