2 * jSite - ClientGet.java - Copyright © 2008–2012 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 2 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, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package de.todesbaum.util.freenet.fcp2;
21 import java.io.IOException;
22 import java.io.Writer;
25 * Implementation of the “ClientGet” command.
27 * @author David ‘BombeB Roden <bombe@freenetproject.org>
29 public class ClientGet extends Command {
31 private boolean ignoreDataStore;
32 private boolean dataStoreOnly;
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;
49 *Creates a new ClientGet command with the given request identifier.
52 * The request identifier
54 public ClientGet(String identifier) {
55 super("ClientGet", identifier);
63 public boolean isIgnoreDataStore() {
64 return ignoreDataStore;
70 * @param ignoreDataStore
72 public void setIgnoreDataStore(boolean ignoreDataStore) {
73 this.ignoreDataStore = ignoreDataStore;
81 public boolean isDataStoreOnly() {
88 * @param dataStoreOnly
90 public void setDataStoreOnly(boolean dataStoreOnly) {
91 this.dataStoreOnly = dataStoreOnly;
99 public String getUri() {
108 public void setUri(String uri) {
117 public Verbosity getVerbosity() {
126 public void setVerbosity(Verbosity verbosity) {
127 this.verbosity = verbosity;
135 public long getMaxSize() {
144 public void setMaxSize(long maxSize) {
145 this.maxSize = maxSize;
153 public long getMaxTempSize() {
162 public void setMaxTempSize(long maxTempSize) {
163 this.maxTempSize = maxTempSize;
171 public int getMaxRetries() {
180 public void setMaxRetries(int maxRetries) {
181 this.maxRetries = maxRetries;
189 public PriorityClass getPriorityClass() {
190 return priorityClass;
196 * @param priorityClass
198 public void setPriorityClass(PriorityClass priorityClass) {
199 this.priorityClass = priorityClass;
207 public Persistence getPersistence() {
216 public void setPersistence(Persistence persistence) {
217 this.persistence = persistence;
225 public String getClientToken() {
234 public void setClientToken(String clientToken) {
235 this.clientToken = clientToken;
243 public boolean isGlobal() {
252 public void setGlobal(boolean global) {
253 this.global = global;
261 public ReturnType getReturnType() {
270 public void setReturnType(ReturnType returnType) {
271 this.returnType = returnType;
279 public boolean isBinaryBlob() {
288 public void setBinaryBlob(boolean binaryBlob) {
289 this.binaryBlob = binaryBlob;
297 public String getAllowedMimeTypes() {
298 return allowedMimeTypes;
304 * @param allowedMimeTypes
306 public void setAllowedMimeTypes(String allowedMimeTypes) {
307 this.allowedMimeTypes = allowedMimeTypes;
315 public String getFilename() {
324 public void setFilename(String filename) {
325 this.filename = filename;
333 public String getTempFilename() {
340 * @param tempFilename
342 public void setTempFilename(String tempFilename) {
343 this.tempFilename = tempFilename;
350 protected void write(Writer writer) throws IOException {
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);
357 writer.write("MaxSize=" + maxSize + LINEFEED);
359 if (maxTempSize > -1) {
360 writer.write("MaxTempSize=" + maxTempSize + LINEFEED);
362 if (maxRetries >= -1) {
363 writer.write("MaxRetries=" + maxRetries + LINEFEED);
365 writer.write("PriorityClass=" + priorityClass.getValue() + LINEFEED);
366 writer.write("Persistence=" + persistence.getName() + LINEFEED);
367 if (clientToken != null) {
368 writer.write("ClientToken=" + clientToken + LINEFEED);
370 writer.write("Global=" + global + LINEFEED);
371 writer.write("BinaryBlob=" + binaryBlob + LINEFEED);
372 if (allowedMimeTypes != null) {
373 writer.write("AllowedMIMETypes=" + allowedMimeTypes + LINEFEED);
375 if (returnType == ReturnType.disk) {
376 writer.write("Filename=" + filename + LINEFEED);
377 if (tempFilename != null) {
378 writer.write("TempFilename=" + tempFilename + LINEFEED);