2 * jFCPlib - ClientGet.java - Copyright © 2008–2016 David Roden
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 3 of the License, or
7 * (at your option) any later version.
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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.fcp;
21 * A “ClientGet” request is used for download files from the Freenet node.
23 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
25 public class ClientGet extends FcpMessage {
28 * Creates a new “ClientGet” request.
33 * The identifier of the request
35 public ClientGet(String uri, String identifier) {
36 this(uri, identifier, ReturnType.direct);
40 * Creates a new “ClientGet” request.
45 * The identifier of the request
47 * The return type of the request
49 public ClientGet(String uri, String identifier, ReturnType returnType) {
52 setField("Identifier", identifier);
53 setField("ReturnType", String.valueOf(returnType));
57 * Sets whether the local data store should be ignored when searching for a
60 * @param ignoreDataStore
61 * <code>true</code> to ignore the local data store,
62 * <code>false</code> to include it
64 public void setIgnoreDataStore(boolean ignoreDataStore) {
65 setField("IgnoreDS", String.valueOf(ignoreDataStore));
69 * Sets whether the search for the key should be restricted to the local
73 * <code>true</code> to restrict the search to the local data
74 * store, <code>false</code> to search on other nodes, too
76 public void setDataStoreOnly(boolean dsOnly) {
77 setField("DSonly", String.valueOf(dsOnly));
81 * Sets the verbosity of the request.
84 * The verbosity of the request
86 public void setVerbosity(Verbosity verbosity) {
87 setField("Verbosity", String.valueOf(verbosity));
91 * Sets the maximum size of the file to retrieve. If the file is larger
92 * than this size the request will fail!
95 * The maximum size of the file to retrieve
97 public void setMaxSize(long maxSize) {
98 setField("MaxSize", String.valueOf(maxSize));
102 * Sets the maximum size of temporary files created by the node. If a
103 * temporary file is larger than this size the request will fail!
106 * The maximum size of temporary files
108 public void setMaxTempSize(long maxTempSize) {
109 setField("MaxTempSize", String.valueOf(maxTempSize));
113 * The maximum number of retries in case a block can not be retrieved.
116 * The maximum number of retries for failed blocks,
117 * <code>-1</code> to try forever
119 public void setMaxRetries(int maxRetries) {
120 setField("MaxRetries", String.valueOf(maxRetries));
124 * Sets the priority of the request.
127 * The priority of the request
129 public void setPriority(Priority priority) {
130 setField("PriorityClass", String.valueOf(priority));
133 public void setRealTimeFlag(boolean realTimeFlag) {
134 setField("RealTimeFlag", String.valueOf(realTimeFlag));
138 * Sets the persistence of the request.
141 * The persistence of the request
143 public void setPersistence(Persistence persistence) {
144 setField("Persistence", String.valueOf(persistence));
148 * Sets the client token of the request.
151 * The client token of the request
153 public void setClientToken(String clientToken) {
154 setField("ClientToken", clientToken);
158 * Sets whether the request should be visible on the global queue.
161 * <code>true</code> to make the request visible on the global
162 * queue, <code>false</code> for client-local queue only
164 public void setGlobal(boolean global) {
165 setField("Global", String.valueOf(global));
169 * Sets whether to request the “binary blob” for a key.
172 * <code>true</code> to request the binary blob,
173 * <code>false</code> to get the “real thing”
175 public void setBinaryBlob(boolean binaryBlob) {
176 setField("BinaryBlob", String.valueOf(binaryBlob));
180 * Sets whether to filter the fetched content.
183 * {@code true} to filter content, {@code false} otherwise
185 public void setFilterData(boolean filterData) {
186 setField("FilterData", String.valueOf(filterData));
190 * Sets the allowed MIME types of the requested file. If the MIME type of
191 * the file does not match one of the given MIME types the request will
194 * @param allowedMimeTypes
195 * The allowed MIME types
197 public void setAllowedMimeTypes(String... allowedMimeTypes) {
198 setField("AllowedMIMETypes", FcpUtils.encodeMultiStringField(allowedMimeTypes));
202 * Sets the filename to download the file to. You should only call this
203 * method if your return type is {@link ReturnType#disk}!
206 * The filename to download the file to
208 public void setFilename(String filename) {
209 setField("Filename", filename);
213 * Sets the name for the temporary file. You should only call this method
214 * if your return type is {@link ReturnType#disk}!
216 * @param tempFilename
217 * The name of the temporary file
219 public void setTempFilename(String tempFilename) {
220 setField("TempFilename", tempFilename);