3a81451c195c984c910adb97209373460cd4b9c2
[jFCPlib.git] / src / net / pterodactylus / fcp / ClientPutDiskDir.java
1 /*
2  * jSite2 - ClientPutDiskDir.java -
3  * Copyright © 2008 David Roden
4  *
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.
9  *
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.
14  *
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.
18  */
19
20 package net.pterodactylus.fcp;
21
22 /**
23  * The “ClientPutDiskDir” message is used to insert a complete directory from
24  * the disk to a single key.
25  * 
26  * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
27  * @version $Id$
28  */
29 public class ClientPutDiskDir extends FcpMessage {
30
31         /**
32          * Creates a new “ClientPutDiskDir” message.
33          * 
34          * @param uri
35          *            The URI to insert the file to
36          * @param identifier
37          *            The identifier of the request
38          * @param directory
39          *            The name of the directory to insert
40          */
41         public ClientPutDiskDir(String uri, String identifier, String directory) {
42                 super("ClientPutDiskDir");
43                 setField("URI", uri);
44                 setField("Identifier", identifier);
45                 setField("Filename", directory);
46         }
47
48         /**
49          * The verbosity of the request. Depending on this parameter you will
50          * received only the bare minimum of messages for the request (i.e. “it
51          * completed”) or a whole lot more.
52          * 
53          * @see Verbosity
54          * @param verbosity
55          *            The verbosity of the request
56          */
57         public void setVerbosity(Verbosity verbosity) {
58                 setField("Verbosity", String.valueOf(verbosity));
59         }
60
61         /**
62          * The number of retries for a request if the initial try failed.
63          * 
64          * @param maxRetries
65          *            The maximum number of retries after failure, or
66          *            <code>-1</code> to retry forever.
67          */
68         public void setMaxRetries(int maxRetries) {
69                 setField("MaxRetries", String.valueOf(maxRetries));
70         }
71
72         /**
73          * Sets the priority of the request.
74          * 
75          * @param priority
76          *            The priority of the request
77          */
78         public void setPriority(Priority priority) {
79                 setField("PriorityClass", String.valueOf(priority));
80         }
81
82         /**
83          * Determines whether the node should really insert the data or generate the
84          * final CHK only.
85          * 
86          * @param getCHKOnly
87          *            <code>true</code> to generate the final CHK only,
88          *            <code>false</code> to really insert the data
89          */
90         public void setGetCHKOnly(boolean getCHKOnly) {
91                 setField("GetCHKOnly", String.valueOf(getCHKOnly));
92         }
93
94         /**
95          * Determines whether this request appears on the global queue.
96          * 
97          * @param global
98          *            <code>true</code> to put the request on the global queue,
99          *            <code>false</code> for the client-local queue.
100          */
101         public void setGlobal(boolean global) {
102                 setField("Global", String.valueOf(global));
103         }
104
105         /**
106          * Determines whether the node should skip compression because the file has
107          * already been compressed.
108          * 
109          * @param dontCompress
110          *            <code>true</code> to skip compression of the data in the
111          *            node, <code>false</code> to allow compression
112          */
113         public void setDontCompress(boolean dontCompress) {
114                 setField("DontCompress", String.valueOf(dontCompress));
115         }
116
117         /**
118          * Sets an optional client token. This client token is mentioned in progress
119          * and other request-related messages and can be used to identify this
120          * request.
121          * 
122          * @param clientToken
123          *            The client token
124          */
125         public void setClientToken(String clientToken) {
126                 setField("ClientToken", clientToken);
127         }
128
129         /**
130          * Sets the persistence of this request.
131          * 
132          * @param persistence
133          *            The persistence of this request
134          */
135         public void setPersistence(Persistence persistence) {
136                 setField("Persistence", String.valueOf(persistence));
137         }
138
139         /**
140          * Sets the name of the default file. The default file is shown when the key
141          * is requested with an additional name.
142          * 
143          * @param defaultName
144          *            The name of the default file
145          */
146         public void setDefaultName(String defaultName) {
147                 setField("DefaultName", defaultName);
148         }
149
150         /**
151          * Sets whether unreadable files allow the insert to continue.
152          * 
153          * @param allowUnreadableFiles
154          *            <code>true</code> to just ignore unreadable files,
155          *            <code>false</code> to let the insert fail when an unreadable
156          *            file is encountered
157          */
158         public void setAllowUnreadableFiles(boolean allowUnreadableFiles) {
159                 setField("AllowUnreadableFiles", String.valueOf(allowUnreadableFiles));
160         }
161
162 }