From f91852416a3be9e8c92ef8477fd24207f0cb5661 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 1 Jul 2008 09:01:23 +0200 Subject: [PATCH] add ClientGet --- src/de/todesbaum/util/freenet/fcp2/ClientGet.java | 384 ++++++++++++++++++++++ 1 file changed, 384 insertions(+) create mode 100644 src/de/todesbaum/util/freenet/fcp2/ClientGet.java diff --git a/src/de/todesbaum/util/freenet/fcp2/ClientGet.java b/src/de/todesbaum/util/freenet/fcp2/ClientGet.java new file mode 100644 index 0000000..d6fb70f --- /dev/null +++ b/src/de/todesbaum/util/freenet/fcp2/ClientGet.java @@ -0,0 +1,384 @@ +/* + * jSite-remote - ClientGet.java - + * Copyright © 2008 David Roden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +package de.todesbaum.util.freenet.fcp2; + +import java.io.IOException; +import java.io.Writer; + +/** + * Implementation of the “ClientGet” command. + * + * @author David ‘BombeB Roden <bombe@freenetproject.org> + */ +public class ClientGet extends Command { + + private boolean ignoreDataStore; + private boolean dataStoreOnly; + private String uri; + private Verbosity verbosity = Verbosity.NONE; + private long maxSize = -1; + private long maxTempSize = -1; + private int maxRetries = -1; + private PriorityClass priorityClass = PriorityClass.INTERACTIVE; + private Persistence persistence = Persistence.CONNECTION; + private String clientToken; + private boolean global = false; + private ReturnType returnType = ReturnType.direct; + private boolean binaryBlob = false; + private String allowedMimeTypes = null; + private String filename = null; + private String tempFilename = null; + + /** + *Creates a new ClientGet command with the given request identifier. + * + * @param identifier + * The request identifier + */ + public ClientGet(String identifier) { + super("ClientGet", identifier); + } + + /** + * TODO + * + * @return + */ + public boolean isIgnoreDataStore() { + return ignoreDataStore; + } + + /** + * TODO + * + * @param ignoreDataStore + */ + public void setIgnoreDataStore(boolean ignoreDataStore) { + this.ignoreDataStore = ignoreDataStore; + } + + /** + * TODO + * + * @return + */ + public boolean isDataStoreOnly() { + return dataStoreOnly; + } + + /** + * TODO + * + * @param dataStoreOnly + */ + public void setDataStoreOnly(boolean dataStoreOnly) { + this.dataStoreOnly = dataStoreOnly; + } + + /** + * TODO + * + * @return + */ + public String getUri() { + return uri; + } + + /** + * TODO + * + * @param uri + */ + public void setUri(String uri) { + this.uri = uri; + } + + /** + * TODO + * + * @return + */ + public Verbosity getVerbosity() { + return verbosity; + } + + /** + * TODO + * + * @param verbosity + */ + public void setVerbosity(Verbosity verbosity) { + this.verbosity = verbosity; + } + + /** + * TODO + * + * @return + */ + public long getMaxSize() { + return maxSize; + } + + /** + * TODO + * + * @param maxSize + */ + public void setMaxSize(long maxSize) { + this.maxSize = maxSize; + } + + /** + * TODO + * + * @return + */ + public long getMaxTempSize() { + return maxTempSize; + } + + /** + * TODO + * + * @param maxTempSize + */ + public void setMaxTempSize(long maxTempSize) { + this.maxTempSize = maxTempSize; + } + + /** + * TODO + * + * @return + */ + public int getMaxRetries() { + return maxRetries; + } + + /** + * TODO + * + * @param maxRetries + */ + public void setMaxRetries(int maxRetries) { + this.maxRetries = maxRetries; + } + + /** + * TODO + * + * @return + */ + public PriorityClass getPriorityClass() { + return priorityClass; + } + + /** + * TODO + * + * @param priorityClass + */ + public void setPriorityClass(PriorityClass priorityClass) { + this.priorityClass = priorityClass; + } + + /** + * TODO + * + * @return + */ + public Persistence getPersistence() { + return persistence; + } + + /** + * TODO + * + * @param persistence + */ + public void setPersistence(Persistence persistence) { + this.persistence = persistence; + } + + /** + * TODO + * + * @return + */ + public String getClientToken() { + return clientToken; + } + + /** + * TODO + * + * @param clientToken + */ + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + /** + * TODO + * + * @return + */ + public boolean isGlobal() { + return global; + } + + /** + * TODO + * + * @param global + */ + public void setGlobal(boolean global) { + this.global = global; + } + + /** + * TODO + * + * @return + */ + public ReturnType getReturnType() { + return returnType; + } + + /** + * TODO + * + * @param returnType + */ + public void setReturnType(ReturnType returnType) { + this.returnType = returnType; + } + + /** + * TODO + * + * @return + */ + public boolean isBinaryBlob() { + return binaryBlob; + } + + /** + * TODO + * + * @param binaryBlob + */ + public void setBinaryBlob(boolean binaryBlob) { + this.binaryBlob = binaryBlob; + } + + /** + * TODO + * + * @return + */ + public String getAllowedMimeTypes() { + return allowedMimeTypes; + } + + /** + * TODO + * + * @param allowedMimeTypes + */ + public void setAllowedMimeTypes(String allowedMimeTypes) { + this.allowedMimeTypes = allowedMimeTypes; + } + + /** + * TODO + * + * @return + */ + public String getFilename() { + return filename; + } + + /** + * TODO + * + * @param filename + */ + public void setFilename(String filename) { + this.filename = filename; + } + + /** + * TODO + * + * @return + */ + public String getTempFilename() { + return tempFilename; + } + + /** + * TODO + * + * @param tempFilename + */ + public void setTempFilename(String tempFilename) { + this.tempFilename = tempFilename; + } + + /** + * {@inheritDoc} + */ + @Override + protected void write(Writer writer) throws IOException { + super.write(writer); + writer.write("IgnoreDS=" + ignoreDataStore + LINEFEED); + writer.write("DSonly=" + dataStoreOnly + LINEFEED); + writer.write("URI=" + uri + LINEFEED); + writer.write("Verbosity=" + verbosity.getValue() + LINEFEED); + if (maxSize > -1) { + writer.write("MaxSize=" + maxSize + LINEFEED); + } + if (maxTempSize > -1) { + writer.write("MaxTempSize=" + maxTempSize + LINEFEED); + } + if (maxRetries >= -1) { + writer.write("MaxRetries=" + maxRetries + LINEFEED); + } + writer.write("PriorityClass=" + priorityClass.getValue() + LINEFEED); + writer.write("Persistence=" + persistence.getName() + LINEFEED); + if (clientToken != null) { + writer.write("ClientToken=" + clientToken + LINEFEED); + } + writer.write("Global=" + global + LINEFEED); + writer.write("BinaryBlob=" + binaryBlob + LINEFEED); + if (allowedMimeTypes != null) { + writer.write("AllowedMIMETypes=" + allowedMimeTypes + LINEFEED); + } + if (returnType == ReturnType.disk) { + writer.write("Filename=" + filename + LINEFEED); + if (tempFilename != null) { + writer.write("TempFilename=" + tempFilename + LINEFEED); + } + } + } + +} -- 2.7.4