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