From 318c1ac4be1c408f0c67719987e8e25a757e0ac9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 10 Apr 2008 16:39:33 +0000 Subject: [PATCH] add ClientGet git-svn-id: http://trooper/svn/projects/jSite/trunk@697 c3eda9e8-030b-0410-8277-bc7414b0a119 --- src/net/pterodactylus/util/fcp/ClientGet.java | 196 ++++++++++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 src/net/pterodactylus/util/fcp/ClientGet.java diff --git a/src/net/pterodactylus/util/fcp/ClientGet.java b/src/net/pterodactylus/util/fcp/ClientGet.java new file mode 100644 index 0000000..8d8c258 --- /dev/null +++ b/src/net/pterodactylus/util/fcp/ClientGet.java @@ -0,0 +1,196 @@ +/** + * © 2008 INA Service GmbH + */ +package net.pterodactylus.util.fcp; + +/** + * A “ClientGet” request is used for download files from the Freenet node. + * + * @author David Roden + * @version $Id$ + */ +public class ClientGet extends FcpMessage { + + /** + * Creates a new “ClientGet” request. + * + * @param uri + * The URI to get + * @param identifier + * The identifier of the request + */ + public ClientGet(String uri, String identifier) { + this(uri, identifier, ReturnType.direct); + } + + /** + * Creates a new “ClientGet” request. + * + * @param uri + * The URI to get + * @param identifier + * The identifier of the request + * @param returnType + * The return type of the request + */ + public ClientGet(String uri, String identifier, ReturnType returnType) { + super("ClientGet"); + setField("URI", uri); + setField("Identifier", identifier); + setField("ReturnType", String.valueOf(returnType)); + } + + /** + * Sets whether the local data store should be ignored when searching for a + * key. + * + * @param ignoreDataStore + * true to ignore the local data store, + * false to include it + */ + public void setIgnoreDataStore(boolean ignoreDataStore) { + setField("IgnoreDS", String.valueOf(ignoreDataStore)); + } + + /** + * Sets whether the search for the key should be restricted to the local + * data store only. + * + * @param dsOnly + * true to restrict the search to the local data + * store, false to search on other nodes, too + */ + public void setDataStoreOnly(boolean dsOnly) { + setField("DSonly", String.valueOf(dsOnly)); + } + + /** + * Sets the verbosity of the request. + * + * @param verbosity + * The verbosity of the request + */ + public void setVerbosity(Verbosity verbosity) { + setField("Verbosity", String.valueOf(verbosity)); + } + + /** + * Sets the maximum size of the file to retrieve. If the file is larger than + * this size the request will fail! + * + * @param maxSize + * The maximum size of the file to retrieve + */ + public void setMaxSize(long maxSize) { + setField("MaxSize", String.valueOf(maxSize)); + } + + /** + * Sets the maximum size of temporary files created by the node. If a + * temporary file is larger than this size the request will fail! + * + * @param maxTempSize + * The maximum size of temporary files + */ + public void setMaxTempSize(long maxTempSize) { + setField("MaxTempSize", String.valueOf(maxTempSize)); + } + + /** + * The maximum number of retries in case a block can not be retrieved. + * + * @param maxRetries + * The maximum number of retries for failed blocks, + * -1 to try forever + */ + public void setMaxRetries(int maxRetries) { + setField("MaxRetries", String.valueOf(maxRetries)); + } + + /** + * Sets the priority of the request. + * + * @param priority + * The priority of the request + */ + public void setPriority(Priority priority) { + setField("PriorityClass", String.valueOf(priority)); + } + + /** + * Sets the persistence of the request. + * + * @param persistence + * The persistence of the request + */ + public void setPersistence(Persistence persistence) { + setField("Persistence", String.valueOf(persistence)); + } + + /** + * Sets the client token of the request. + * + * @param clientToken + * The client token of the request + */ + public void setClientToken(String clientToken) { + setField("ClientToken", clientToken); + } + + /** + * Sets whether the request should be visible on the global queue. + * + * @param global + * true to make the request visible on the global + * queue, false for client-local queue only + */ + public void setGlobal(boolean global) { + setField("Global", String.valueOf(global)); + } + + /** + * Sets whether to request the “binary blob” for a key. + * + * @param binaryBlob + * true to request the binary blob, + * false to get the “real thing” + */ + public void setBinaryBlob(boolean binaryBlob) { + setField("BinaryBlob", String.valueOf(binaryBlob)); + } + + /** + * Sets the allowed MIME types of the requested file. If the MIME type of + * the file does not match one of the given MIME types the request will + * fail! + * + * @param allowedMimeTypes + * The allowed MIME types + */ + public void setAllowedMimeTypes(String... allowedMimeTypes) { + setField("AllowedMIMETypes", FcpUtils.encodeMultiStringField(allowedMimeTypes)); + } + + /** + * Sets the filename to download the file to. You should only call this + * method if your return type is {@link ReturnType#disk}! + * + * @param filename + * The filename to download the file to + */ + public void setFilename(String filename) { + setField("Filename", filename); + } + + /** + * Sets the name for the temporary file. You should only call this method if + * your return type is {@link ReturnType#disk}! + * + * @param tempFilename + * The name of the temporary file + */ + public void setTempFilename(String tempFilename) { + setField("TempFilename", tempFilename); + } + +} -- 2.7.4