Throw an exception when the node is not connected.
[jSite.git] / src / de / todesbaum / util / freenet / fcp2 / ClientGet.java
1 /*
2  * jSite-remote - ClientGet.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 de.todesbaum.util.freenet.fcp2;
21
22 import java.io.IOException;
23 import java.io.Writer;
24
25 /**
26  * Implementation of the “ClientGet” command.
27  *
28  * @author David ‘BombeB Roden <bombe@freenetproject.org>
29  */
30 public class ClientGet extends Command {
31
32         private boolean ignoreDataStore;
33         private boolean dataStoreOnly;
34         private String uri;
35         private Verbosity verbosity = Verbosity.NONE;
36         private long maxSize = -1;
37         private long maxTempSize = -1;
38         private int maxRetries = -1;
39         private PriorityClass priorityClass = PriorityClass.INTERACTIVE;
40         private Persistence persistence = Persistence.CONNECTION;
41         private String clientToken;
42         private boolean global = false;
43         private ReturnType returnType = ReturnType.direct;
44         private boolean binaryBlob = false;
45         private String allowedMimeTypes = null;
46         private String filename = null;
47         private String tempFilename = null;
48
49         /**
50          *Creates a new ClientGet command with the given request identifier.
51          *
52          * @param identifier
53          *            The request identifier
54          */
55         public ClientGet(String identifier) {
56                 super("ClientGet", identifier);
57         }
58
59         /**
60          * TODO
61          *
62          * @return
63          */
64         public boolean isIgnoreDataStore() {
65                 return ignoreDataStore;
66         }
67
68         /**
69          * TODO
70          *
71          * @param ignoreDataStore
72          */
73         public void setIgnoreDataStore(boolean ignoreDataStore) {
74                 this.ignoreDataStore = ignoreDataStore;
75         }
76
77         /**
78          * TODO
79          *
80          * @return
81          */
82         public boolean isDataStoreOnly() {
83                 return dataStoreOnly;
84         }
85
86         /**
87          * TODO
88          *
89          * @param dataStoreOnly
90          */
91         public void setDataStoreOnly(boolean dataStoreOnly) {
92                 this.dataStoreOnly = dataStoreOnly;
93         }
94
95         /**
96          * TODO
97          *
98          * @return
99          */
100         public String getUri() {
101                 return uri;
102         }
103
104         /**
105          * TODO
106          *
107          * @param uri
108          */
109         public void setUri(String uri) {
110                 this.uri = uri;
111         }
112
113         /**
114          * TODO
115          *
116          * @return
117          */
118         public Verbosity getVerbosity() {
119                 return verbosity;
120         }
121
122         /**
123          * TODO
124          *
125          * @param verbosity
126          */
127         public void setVerbosity(Verbosity verbosity) {
128                 this.verbosity = verbosity;
129         }
130
131         /**
132          * TODO
133          *
134          * @return
135          */
136         public long getMaxSize() {
137                 return maxSize;
138         }
139
140         /**
141          * TODO
142          *
143          * @param maxSize
144          */
145         public void setMaxSize(long maxSize) {
146                 this.maxSize = maxSize;
147         }
148
149         /**
150          * TODO
151          *
152          * @return
153          */
154         public long getMaxTempSize() {
155                 return maxTempSize;
156         }
157
158         /**
159          * TODO
160          *
161          * @param maxTempSize
162          */
163         public void setMaxTempSize(long maxTempSize) {
164                 this.maxTempSize = maxTempSize;
165         }
166
167         /**
168          * TODO
169          *
170          * @return
171          */
172         public int getMaxRetries() {
173                 return maxRetries;
174         }
175
176         /**
177          * TODO
178          *
179          * @param maxRetries
180          */
181         public void setMaxRetries(int maxRetries) {
182                 this.maxRetries = maxRetries;
183         }
184
185         /**
186          * TODO
187          *
188          * @return
189          */
190         public PriorityClass getPriorityClass() {
191                 return priorityClass;
192         }
193
194         /**
195          * TODO
196          *
197          * @param priorityClass
198          */
199         public void setPriorityClass(PriorityClass priorityClass) {
200                 this.priorityClass = priorityClass;
201         }
202
203         /**
204          * TODO
205          *
206          * @return
207          */
208         public Persistence getPersistence() {
209                 return persistence;
210         }
211
212         /**
213          * TODO
214          *
215          * @param persistence
216          */
217         public void setPersistence(Persistence persistence) {
218                 this.persistence = persistence;
219         }
220
221         /**
222          * TODO
223          *
224          * @return
225          */
226         public String getClientToken() {
227                 return clientToken;
228         }
229
230         /**
231          * TODO
232          *
233          * @param clientToken
234          */
235         public void setClientToken(String clientToken) {
236                 this.clientToken = clientToken;
237         }
238
239         /**
240          * TODO
241          *
242          * @return
243          */
244         public boolean isGlobal() {
245                 return global;
246         }
247
248         /**
249          * TODO
250          *
251          * @param global
252          */
253         public void setGlobal(boolean global) {
254                 this.global = global;
255         }
256
257         /**
258          * TODO
259          *
260          * @return
261          */
262         public ReturnType getReturnType() {
263                 return returnType;
264         }
265
266         /**
267          * TODO
268          *
269          * @param returnType
270          */
271         public void setReturnType(ReturnType returnType) {
272                 this.returnType = returnType;
273         }
274
275         /**
276          * TODO
277          *
278          * @return
279          */
280         public boolean isBinaryBlob() {
281                 return binaryBlob;
282         }
283
284         /**
285          * TODO
286          *
287          * @param binaryBlob
288          */
289         public void setBinaryBlob(boolean binaryBlob) {
290                 this.binaryBlob = binaryBlob;
291         }
292
293         /**
294          * TODO
295          *
296          * @return
297          */
298         public String getAllowedMimeTypes() {
299                 return allowedMimeTypes;
300         }
301
302         /**
303          * TODO
304          *
305          * @param allowedMimeTypes
306          */
307         public void setAllowedMimeTypes(String allowedMimeTypes) {
308                 this.allowedMimeTypes = allowedMimeTypes;
309         }
310
311         /**
312          * TODO
313          *
314          * @return
315          */
316         public String getFilename() {
317                 return filename;
318         }
319
320         /**
321          * TODO
322          *
323          * @param filename
324          */
325         public void setFilename(String filename) {
326                 this.filename = filename;
327         }
328
329         /**
330          * TODO
331          *
332          * @return
333          */
334         public String getTempFilename() {
335                 return tempFilename;
336         }
337
338         /**
339          * TODO
340          *
341          * @param tempFilename
342          */
343         public void setTempFilename(String tempFilename) {
344                 this.tempFilename = tempFilename;
345         }
346
347         /**
348          * {@inheritDoc}
349          */
350         @Override
351         protected void write(Writer writer) throws IOException {
352                 super.write(writer);
353                 writer.write("IgnoreDS=" + ignoreDataStore + LINEFEED);
354                 writer.write("DSonly=" + dataStoreOnly + LINEFEED);
355                 writer.write("URI=" + uri + LINEFEED);
356                 writer.write("Verbosity=" + verbosity.getValue() + LINEFEED);
357                 if (maxSize > -1) {
358                         writer.write("MaxSize=" + maxSize + LINEFEED);
359                 }
360                 if (maxTempSize > -1) {
361                         writer.write("MaxTempSize=" + maxTempSize + LINEFEED);
362                 }
363                 if (maxRetries >= -1) {
364                         writer.write("MaxRetries=" + maxRetries + LINEFEED);
365                 }
366                 writer.write("PriorityClass=" + priorityClass.getValue() + LINEFEED);
367                 writer.write("Persistence=" + persistence.getName() + LINEFEED);
368                 if (clientToken != null) {
369                         writer.write("ClientToken=" + clientToken + LINEFEED);
370                 }
371                 writer.write("Global=" + global + LINEFEED);
372                 writer.write("BinaryBlob=" + binaryBlob + LINEFEED);
373                 if (allowedMimeTypes != null) {
374                         writer.write("AllowedMIMETypes=" + allowedMimeTypes + LINEFEED);
375                 }
376                 if (returnType == ReturnType.disk) {
377                         writer.write("Filename=" + filename + LINEFEED);
378                         if (tempFilename != null) {
379                                 writer.write("TempFilename=" + tempFilename + LINEFEED);
380                         }
381                 }
382         }
383
384 }