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