9b6b3321c3cfb0bbe24278a80232dbbdfc29e455
[jSite.git] / src / main / java / de / todesbaum / jsite / application / InsertListener.java
1 /*
2  * jSite - InsertListener.java - Copyright © 2006–2012 David Roden
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18
19 package de.todesbaum.jsite.application;
20
21 import java.util.EventListener;
22
23 /**
24  * Interface for objects that want to be notified abount insert events.
25  *
26  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
27  */
28 public interface InsertListener extends EventListener {
29
30         /**
31          * Enumeration for the different error situations.
32          *
33          * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
34          */
35         public static enum ErrorType {
36
37                 /** The key does already exist. */
38                 KEY_COLLISION,
39
40                 /** The route to the key was not found. */
41                 ROUTE_NOT_FOUND,
42
43                 /** The data was not found. */
44                 DATA_NOT_FOUND,
45
46                 /** Error in the FCP communication. */
47                 FCP_ERROR,
48
49                 /** General error in the communication. */
50                 IO_ERROR
51         }
52
53         /**
54          * Notifies a listener that an insert has started.
55          *
56          * @param project
57          *            The project that is now being inserted
58          */
59         public void projectInsertStarted(Project project);
60
61         /**
62          * Notifies a listener that the upload of a project has finished and the
63          * inserting will start now.
64          *
65          * @param project
66          *            The project that has been uploaded
67          */
68         public void projectUploadFinished(Project project);
69
70         /**
71          * Notifies a listener that a project insert has generated a URI.
72          *
73          * @param project
74          *            The project being inserted
75          * @param uri
76          *            The generated URI
77          */
78         public void projectURIGenerated(Project project, String uri);
79
80         /**
81          * Notifies a listener that an insert has made some progress.
82          *
83          * @param project
84          *            The project being inserted
85          * @param succeeded
86          *            The number of succeeded blocks
87          * @param failed
88          *            The number of failed blocks
89          * @param fatal
90          *            The number of fatally failed blocks
91          * @param total
92          *            The total number of blocks
93          * @param finalized
94          *            <code>true</code> if the total number of blocks has been
95          *            finalized, <code>false</code> otherwise
96          */
97         public void projectInsertProgress(Project project, int succeeded, int failed, int fatal, int total, boolean finalized);
98
99         /**
100          * Notifies a listener that a project insert has finished.
101          *
102          * @param project
103          *            The project being inserted
104          * @param success
105          *            <code>true</code> if the insert succeeded, <code>false</code>
106          *            otherwise
107          * @param cause
108          *            The cause of a failure, if any (may be <code>null</code>)
109          */
110         public void projectInsertFinished(Project project, boolean success, Throwable cause);
111
112 }