40cdaf17075a2e7dbcecfe3ec9884392c44446d2
[jSite.git] / src / de / todesbaum / jsite / application / InsertListener.java
1 /*
2  * jSite - a tool for uploading websites into Freenet
3  * Copyright (C) 2006 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 de.todesbaum.jsite.application;
21
22 import java.util.EventListener;
23
24 /**
25  * Interface for objects that want to be notified abount insert events.
26  *
27  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
28  */
29 public interface InsertListener extends EventListener {
30
31         /**
32          * Enumeration for the different error situations.
33          *
34          * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
35          */
36         public static enum ErrorType {
37
38                 /** The key does already exist. */
39                 KEY_COLLISION,
40
41                 /** The route to the key was not found. */
42                 ROUTE_NOT_FOUND,
43
44                 /** The data was not found. */
45                 DATA_NOT_FOUND,
46
47                 /** Error in the FCP communication. */
48                 FCP_ERROR,
49
50                 /** General error in the communication. */
51                 IO_ERROR
52         }
53
54         /**
55          * Notifies a listener that an insert has started.
56          *
57          * @param project
58          *            The project that is now being inserted
59          */
60         public void projectInsertStarted(Project project);
61
62         /**
63          * Notifies a listener that the upload of a project has finished and the
64          * inserting will start now.
65          *
66          * @param project
67          *            The project that has been uploaded
68          */
69         public void projectUploadFinished(Project project);
70
71         /**
72          * Notifies a listener that a project insert has generated a URI.
73          *
74          * @param project
75          *            The project being inserted
76          * @param uri
77          *            The generated URI
78          */
79         public void projectURIGenerated(Project project, String uri);
80
81         /**
82          * Notifies a listener that an insert has made some progress.
83          *
84          * @param project
85          *            The project being inserted
86          * @param succeeded
87          *            The number of succeeded blocks
88          * @param failed
89          *            The number of failed blocks
90          * @param fatal
91          *            The number of fatally failed blocks
92          * @param total
93          *            The total number of blocks
94          * @param finalized
95          *            <code>true</code> if the total number of blocks has been
96          *            finalized, <code>false</code> otherwise
97          */
98         public void projectInsertProgress(Project project, int succeeded, int failed, int fatal, int total, boolean finalized);
99
100         /**
101          * Notifies a listener that a project insert has finished.
102          *
103          * @param project
104          *            The project being inserted
105          * @param success
106          *            <code>true</code> if the insert succeeded, <code>false</code>
107          *            otherwise
108          * @param cause
109          *            The cause of a failure, if any (may be <code>null</code>)
110          */
111         public void projectInsertFinished(Project project, boolean success, Throwable cause);
112
113 }