2 * jSite2 - ClientGet.java -
3 * Copyright © 2008 David Roden
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.
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.
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.
20 package net.pterodactylus.fcp;
23 * A “ClientGet” request is used for download files from the Freenet node.
25 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
28 public class ClientGet extends FcpMessage {
31 * Creates a new “ClientGet” request.
36 * The identifier of the request
38 public ClientGet(String uri, String identifier) {
39 this(uri, identifier, ReturnType.direct);
43 * Creates a new “ClientGet” request.
48 * The identifier of the request
50 * The return type of the request
52 public ClientGet(String uri, String identifier, ReturnType returnType) {
55 setField("Identifier", identifier);
56 setField("ReturnType", String.valueOf(returnType));
60 * Sets whether the local data store should be ignored when searching for a
63 * @param ignoreDataStore
64 * <code>true</code> to ignore the local data store,
65 * <code>false</code> to include it
67 public void setIgnoreDataStore(boolean ignoreDataStore) {
68 setField("IgnoreDS", String.valueOf(ignoreDataStore));
72 * Sets whether the search for the key should be restricted to the local
76 * <code>true</code> to restrict the search to the local data
77 * store, <code>false</code> to search on other nodes, too
79 public void setDataStoreOnly(boolean dsOnly) {
80 setField("DSonly", String.valueOf(dsOnly));
84 * Sets the verbosity of the request.
87 * The verbosity of the request
89 public void setVerbosity(Verbosity verbosity) {
90 setField("Verbosity", String.valueOf(verbosity));
94 * Sets the maximum size of the file to retrieve. If the file is larger than
95 * this size the request will fail!
98 * The maximum size of the file to retrieve
100 public void setMaxSize(long maxSize) {
101 setField("MaxSize", String.valueOf(maxSize));
105 * Sets the maximum size of temporary files created by the node. If a
106 * temporary file is larger than this size the request will fail!
109 * The maximum size of temporary files
111 public void setMaxTempSize(long maxTempSize) {
112 setField("MaxTempSize", String.valueOf(maxTempSize));
116 * The maximum number of retries in case a block can not be retrieved.
119 * The maximum number of retries for failed blocks,
120 * <code>-1</code> to try forever
122 public void setMaxRetries(int maxRetries) {
123 setField("MaxRetries", String.valueOf(maxRetries));
127 * Sets the priority of the request.
130 * The priority of the request
132 public void setPriority(Priority priority) {
133 setField("PriorityClass", String.valueOf(priority));
137 * Sets the persistence of the request.
140 * The persistence of the request
142 public void setPersistence(Persistence persistence) {
143 setField("Persistence", String.valueOf(persistence));
147 * Sets the client token of the request.
150 * The client token of the request
152 public void setClientToken(String clientToken) {
153 setField("ClientToken", clientToken);
157 * Sets whether the request should be visible on the global queue.
160 * <code>true</code> to make the request visible on the global
161 * queue, <code>false</code> for client-local queue only
163 public void setGlobal(boolean global) {
164 setField("Global", String.valueOf(global));
168 * Sets whether to request the “binary blob” for a key.
171 * <code>true</code> to request the binary blob,
172 * <code>false</code> to get the “real thing”
174 public void setBinaryBlob(boolean binaryBlob) {
175 setField("BinaryBlob", String.valueOf(binaryBlob));
179 * Sets the allowed MIME types of the requested file. If the MIME type of
180 * the file does not match one of the given MIME types the request will
183 * @param allowedMimeTypes
184 * The allowed MIME types
186 public void setAllowedMimeTypes(String... allowedMimeTypes) {
187 setField("AllowedMIMETypes", FcpUtils.encodeMultiStringField(allowedMimeTypes));
191 * Sets the filename to download the file to. You should only call this
192 * method if your return type is {@link ReturnType#disk}!
195 * The filename to download the file to
197 public void setFilename(String filename) {
198 setField("Filename", filename);
202 * Sets the name for the temporary file. You should only call this method if
203 * your return type is {@link ReturnType#disk}!
205 * @param tempFilename
206 * The name of the temporary file
208 public void setTempFilename(String tempFilename) {
209 setField("TempFilename", tempFilename);