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>
27 public class ClientGet extends FcpMessage {
30 * Creates a new “ClientGet” request.
35 * The identifier of the request
37 public ClientGet(String uri, String identifier) {
38 this(uri, identifier, ReturnType.direct);
42 * Creates a new “ClientGet” request.
47 * The identifier of the request
49 * The return type of the request
51 public ClientGet(String uri, String identifier, ReturnType returnType) {
54 setField("Identifier", identifier);
55 setField("ReturnType", String.valueOf(returnType));
59 * Sets whether the local data store should be ignored when searching for a
62 * @param ignoreDataStore
63 * <code>true</code> to ignore the local data store,
64 * <code>false</code> to include it
66 public void setIgnoreDataStore(boolean ignoreDataStore) {
67 setField("IgnoreDS", String.valueOf(ignoreDataStore));
71 * Sets whether the search for the key should be restricted to the local
75 * <code>true</code> to restrict the search to the local data
76 * store, <code>false</code> to search on other nodes, too
78 public void setDataStoreOnly(boolean dsOnly) {
79 setField("DSonly", String.valueOf(dsOnly));
83 * Sets the verbosity of the request.
86 * The verbosity of the request
88 public void setVerbosity(Verbosity verbosity) {
89 setField("Verbosity", String.valueOf(verbosity));
93 * Sets the maximum size of the file to retrieve. If the file is larger than
94 * this size the request will fail!
97 * The maximum size of the file to retrieve
99 public void setMaxSize(long maxSize) {
100 setField("MaxSize", String.valueOf(maxSize));
104 * Sets the maximum size of temporary files created by the node. If a
105 * temporary file is larger than this size the request will fail!
108 * The maximum size of temporary files
110 public void setMaxTempSize(long maxTempSize) {
111 setField("MaxTempSize", String.valueOf(maxTempSize));
115 * The maximum number of retries in case a block can not be retrieved.
118 * The maximum number of retries for failed blocks,
119 * <code>-1</code> to try forever
121 public void setMaxRetries(int maxRetries) {
122 setField("MaxRetries", String.valueOf(maxRetries));
126 * Sets the priority of the request.
129 * The priority of the request
131 public void setPriority(Priority priority) {
132 setField("PriorityClass", String.valueOf(priority));
136 * Sets the persistence of the request.
139 * The persistence of the request
141 public void setPersistence(Persistence persistence) {
142 setField("Persistence", String.valueOf(persistence));
146 * Sets the client token of the request.
149 * The client token of the request
151 public void setClientToken(String clientToken) {
152 setField("ClientToken", clientToken);
156 * Sets whether the request should be visible on the global queue.
159 * <code>true</code> to make the request visible on the global
160 * queue, <code>false</code> for client-local queue only
162 public void setGlobal(boolean global) {
163 setField("Global", String.valueOf(global));
167 * Sets whether to request the “binary blob” for a key.
170 * <code>true</code> to request the binary blob,
171 * <code>false</code> to get the “real thing”
173 public void setBinaryBlob(boolean binaryBlob) {
174 setField("BinaryBlob", String.valueOf(binaryBlob));
178 * Sets the allowed MIME types of the requested file. If the MIME type of
179 * the file does not match one of the given MIME types the request will
182 * @param allowedMimeTypes
183 * The allowed MIME types
185 public void setAllowedMimeTypes(String... allowedMimeTypes) {
186 setField("AllowedMIMETypes", FcpUtils.encodeMultiStringField(allowedMimeTypes));
190 * Sets the filename to download the file to. You should only call this
191 * method if your return type is {@link ReturnType#disk}!
194 * The filename to download the file to
196 public void setFilename(String filename) {
197 setField("Filename", filename);
201 * Sets the name for the temporary file. You should only call this method if
202 * your return type is {@link ReturnType#disk}!
204 * @param tempFilename
205 * The name of the temporary file
207 public void setTempFilename(String tempFilename) {
208 setField("TempFilename", tempFilename);