1 | // |
---|
2 | // $Id: UploadPolicy.java 287 2007-06-17 09:07:04 +0000 (dim., 17 juin 2007) |
---|
3 | // felfert $ |
---|
4 | // |
---|
5 | // jupload - A file upload applet. |
---|
6 | // Copyright 2007 The JUpload Team |
---|
7 | // |
---|
8 | // Created: 2006-05-04 |
---|
9 | // Creator: etienne_sf |
---|
10 | // Last modified: $Date: 2010-08-18 08:23:24 -0300 (Qua, 18 Ago 2010) $ |
---|
11 | // |
---|
12 | // This program is free software; you can redistribute it and/or modify it under |
---|
13 | // the terms of the GNU General Public License as published by the Free Software |
---|
14 | // Foundation; either version 2 of the License, or (at your option) any later |
---|
15 | // version. This program is distributed in the hope that it will be useful, but |
---|
16 | // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
17 | // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
---|
18 | // details. You should have received a copy of the GNU General Public License |
---|
19 | // along with this program; if not, write to the Free Software Foundation, Inc., |
---|
20 | // 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
21 | |
---|
22 | package wjhk.jupload2.policies; |
---|
23 | |
---|
24 | import java.awt.Cursor; |
---|
25 | import java.awt.dnd.DropTargetDropEvent; |
---|
26 | import java.io.File; |
---|
27 | import java.util.Locale; |
---|
28 | |
---|
29 | import javax.swing.Icon; |
---|
30 | import javax.swing.JButton; |
---|
31 | import javax.swing.JLabel; |
---|
32 | import javax.swing.JOptionPane; |
---|
33 | import javax.swing.JPanel; |
---|
34 | import javax.swing.JProgressBar; |
---|
35 | import javax.swing.filechooser.FileFilter; |
---|
36 | |
---|
37 | import wjhk.jupload2.context.JUploadContext; |
---|
38 | import wjhk.jupload2.exception.JUploadException; |
---|
39 | import wjhk.jupload2.exception.JUploadExceptionStopAddingFiles; |
---|
40 | import wjhk.jupload2.exception.JUploadIOException; |
---|
41 | import wjhk.jupload2.filedata.FileData; |
---|
42 | import wjhk.jupload2.gui.JUploadFileChooser; |
---|
43 | import wjhk.jupload2.gui.JUploadFileFilter; |
---|
44 | import wjhk.jupload2.gui.JUploadFileView; |
---|
45 | import wjhk.jupload2.gui.JUploadPanel; |
---|
46 | import wjhk.jupload2.gui.image.PictureDialog; |
---|
47 | import wjhk.jupload2.upload.helper.ByteArrayEncoder; |
---|
48 | |
---|
49 | /** |
---|
50 | * This package contains upload policies, which allow easy configuration of the |
---|
51 | * applet behavior. <br> |
---|
52 | * <br> |
---|
53 | * The class {@link DefaultUploadPolicy} contains a default implementation for |
---|
54 | * all UploadPolicy methods. <br> |
---|
55 | * <br> |
---|
56 | * <h4><a name="parameters">Parameters</a></h4> <!-- ATTENTION: The following |
---|
57 | * comment is used by Ant build. DO NOT CHANGE!! --> <!-- ANT_COPYDOC_START --> |
---|
58 | * <p> |
---|
59 | * Here is the list of all parameters available in the current package, that is: |
---|
60 | * available in available upload policies. These are applet parameters that can |
---|
61 | * be 'given' to the applet, with <PARAM> tags, as explained below in the <a |
---|
62 | * href="#example">example</a>. |
---|
63 | * </p> |
---|
64 | * <P> |
---|
65 | * Let's start with some hints: <DIR> |
---|
66 | * <LI><A href="debugLevel">debugLevel</A> and <A |
---|
67 | * href="showLogWindow">showLogWindow</A>: I recommend putting debugLevel to 99 |
---|
68 | * and showLogWindow to onError. |
---|
69 | * <LI><A href="maxFileSize">maxFileSize</A>: this prevents the user to upload |
---|
70 | * too big files. The value depends on your needs. |
---|
71 | * <LI><A href="#maxChunkSize">maxChunkSize</A>: allows you to override the |
---|
72 | * server's maximum upload file size. The uploaded file will be split in pieces |
---|
73 | * of maxChunkSize bytes. Then, it's up to you to concatenate the file pieces, |
---|
74 | * into a server script. There are sample in this doc, and in the JUpload wiki. |
---|
75 | * Please add your samples also...</DIR> |
---|
76 | * </P> |
---|
77 | * <table border="1"> |
---|
78 | * <tr> |
---|
79 | * <th>Parameter name</th> |
---|
80 | * <th>Default value / <br> |
---|
81 | * Implemented in</th> |
---|
82 | * <th>Description</th> |
---|
83 | * </tr> |
---|
84 | * <tr> |
---|
85 | * <td>afterUploadTarget<br> |
---|
86 | * Since 2.9.2rc4</td> |
---|
87 | * <td>_self<br> |
---|
88 | * <br> |
---|
89 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
90 | * <td>This parameter allows to select a specific target frame when redirecting |
---|
91 | * to <code>afterUploadURL</code>. The following values are possible:<br> |
---|
92 | * <ul> |
---|
93 | * <li><code>_self</code> - Show in the window and frame that contain the |
---|
94 | * applet.</li> |
---|
95 | * <li><code>_parent</code> - Show in the applet's parent frame. If the applet's |
---|
96 | * frame has no parent frame, acts the same as <i>_self</i>.</li> |
---|
97 | * <li><code>_top</code> - Show in the top-level frame of the applet's window. |
---|
98 | * If the applet's frame is the top-level frame, acts the same as <i>_self</i>.</li> |
---|
99 | * <li><code>_blank</code> - Show in a new, unnamed top-level window. |
---|
100 | * <li><i>name</i> - Show in the frame or window named <i>name</i>. If a target |
---|
101 | * named <i>name</i> does not already exist, a new top-level window with the |
---|
102 | * specified name is created, and the document is shown there.</li> |
---|
103 | * </ul> |
---|
104 | * See also: |
---|
105 | * {@link java.applet.AppletContext#showDocument(java.net.URL, java.lang.String)} |
---|
106 | * </td> |
---|
107 | * </tr> |
---|
108 | * <tr> |
---|
109 | * <td>afterUploadURL</td> |
---|
110 | * <td><i>null</i><br> |
---|
111 | * since 2.9.0<br> |
---|
112 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
113 | * <td>This parameter is used by all policies. It allows the applet to change |
---|
114 | * the current page to another one after a successful upload. <br> |
---|
115 | * This allows, for instance, to display a page containing the file description |
---|
116 | * of the newly uploaded page. Since version 3.0.2b2, you can specify a |
---|
117 | * JavaScript expression instead of a plain URL. So afterUploadURL can now |
---|
118 | * contain:<br> |
---|
119 | * <UL> |
---|
120 | * <LI><B>A javascript expression</B>: The URL must start by <I>javascript:</I>. |
---|
121 | * See below for details.</LI> |
---|
122 | * <LI><B>A http URL</B>: the navigator will open this URL, in the current page |
---|
123 | * or another, according to the <I>afterUploadTarget</I> parameter. Any URL that |
---|
124 | * doesn't start by <I>javascript:</I> is handled as an http URL.</LI> |
---|
125 | * </UL> |
---|
126 | * If the value of afterUploadURL starts with the string "javascript:", the |
---|
127 | * remainder of the string is evaluated as JavaScript expression in the current |
---|
128 | * document context. For example: If afterUloadURL is<br> |
---|
129 | * <code>"javascript:alert('Thanks for the upload');"</code>,</br> then after a |
---|
130 | * successful upload, a messagebox would pop up. Since 3.0.2b3 there are now |
---|
131 | * three place holders available which can be used as parameters in function |
---|
132 | * calls: |
---|
133 | * <ul> |
---|
134 | * <li><code>%success%</code> is replaced by <b>true</b> or <b>false</b> |
---|
135 | * depending on upload success. |
---|
136 | * <li><code>%msg%</code> is replaced by an unquoted string, containing the |
---|
137 | * error message received from the server (if any). Inside that string, all |
---|
138 | * occurrences of the single-quote character (hex 27) are quoted by backslashes. |
---|
139 | * <li><code>%body%</code> is replaced by an unquoted string, containing the |
---|
140 | * complete response body. Inside that string, all occurrences of the |
---|
141 | * single-quote character (hex 27) are quoted by backslashes. |
---|
142 | * </ul> |
---|
143 | * So if you set afterUloadURL to <code>"javascript:alert('%body%');"</code>, |
---|
144 | * then the resulting message box will show the body content of the last server |
---|
145 | * response.</td> |
---|
146 | * </tr> |
---|
147 | * <tr> |
---|
148 | * <td>albumId</td> |
---|
149 | * <td>-1 <br> |
---|
150 | * <br> |
---|
151 | * {@link wjhk.jupload2.policies.CoppermineUploadPolicy}</td> |
---|
152 | * <td>This parameter is only used by CoppermineUploadPolicy. So it is to be |
---|
153 | * used to upload into a <a href="http://coppermine.sourceforge.net/">coppermine |
---|
154 | * picture gallery</a>. This parameter contains the identifier of the album, |
---|
155 | * where pictures should be used. See CoppermineUploadPolicy for an example. <br> |
---|
156 | * Before upload, CoppermineUploadPolicy. |
---|
157 | * {@link wjhk.jupload2.policies.CoppermineUploadPolicy#beforeUpload()} checks |
---|
158 | * that the albumId is correct, that is: >=1.</td> |
---|
159 | * </tr> |
---|
160 | * <tr> |
---|
161 | * <td>allowedFileExtensions</td> |
---|
162 | * <td><i>empty string</i><br> |
---|
163 | * since 2.9.0<br> |
---|
164 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
165 | * <td>This parameter allows the caller to specify a list of file extension. If |
---|
166 | * this parameter is specified, only file with this extension can be selected in |
---|
167 | * the applet.<br> |
---|
168 | * This parameter must contains a list of extensions, in lower case, separated |
---|
169 | * by slashes. eg: jpg/jpeg/gif</td> |
---|
170 | * </tr> |
---|
171 | * <tr> |
---|
172 | * <td>allowHttpPersistent</td> |
---|
173 | * <td><i>false</i><br> |
---|
174 | * since 3.0.0rc1<br> |
---|
175 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
176 | * <td>This parameter allows to switch off persistent HTTP connections which are |
---|
177 | * enabled by default (and the protocol version allows it). Currently, we |
---|
178 | * encountered problems with persistent connections when testing on a windows |
---|
179 | * box using a loopback interface only. <BR> |
---|
180 | * Note: default value changed to false in 4.0 version.</td> |
---|
181 | * </tr> |
---|
182 | * <tr> |
---|
183 | * <td>browsingDirectory</td> |
---|
184 | * <td><i>null</i><br> |
---|
185 | * since 4.0.0b2<br> |
---|
186 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
187 | * <td>This parameter allows to control the starting browsing directory, that |
---|
188 | * is, the directory the is the current one when the file chooser is open.<BR> |
---|
189 | * <U>Notes:</U> <DIR> |
---|
190 | * <UL> |
---|
191 | * If the directory doesn't exist, or can not be read, a warning is written on |
---|
192 | * the local log window (visible only in debug mode), and this parameter is |
---|
193 | * ignored. |
---|
194 | * <UL> |
---|
195 | * This directory may begin with ~/ or ~\, to have a path set relative to the |
---|
196 | * current user's home.</DIR> |
---|
197 | * </td> |
---|
198 | * </tr> |
---|
199 | * <tr> |
---|
200 | * <td>debugLevel</td> |
---|
201 | * <td>0 <br> |
---|
202 | * <br> |
---|
203 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
204 | * <td>With 0, you get the normal production output. The higher the number is, |
---|
205 | * the more information is displayed in the log window. Here are some hints |
---|
206 | * about debug level values (please note that this is indicative ... including |
---|
207 | * for me, as I'me writing this during 3.3.2 release: <DIR> |
---|
208 | * <LI>0: No debug output. Only INFO and ERROR |
---|
209 | * <LI>10: Structural debug output (entering method, exception info...) |
---|
210 | * <LI>30: Details about method parameters |
---|
211 | * <LI>50: Details about internal method variables. |
---|
212 | * <LI>70: Details about encoding toward the server |
---|
213 | * <LI>80: Details about server's response |
---|
214 | * <LI>90: Details about query and server response when sending debug output to |
---|
215 | * urlToSendErrorTo |
---|
216 | * <LI>100: Maximum output information level. The redirection toward |
---|
217 | * afterUploadURL is blocked |
---|
218 | * <LI>>100: Additional things for internal debug, like some wait in the code to |
---|
219 | * check what messages the applet displays, while uploading small files on |
---|
220 | * localhost.</DIR> <br> |
---|
221 | * Note: All debug messages are stored in a temporary log file. This can be used |
---|
222 | * to display more information, if needed. See also the <I>urlToSendErrorTo</I> |
---|
223 | * applet parameter.</td> |
---|
224 | * </tr> |
---|
225 | * <tr> |
---|
226 | * <td>fileChooserIconFromFileContent</td> |
---|
227 | * <td><i>0</i><br> |
---|
228 | * since 3.1.0b<br> |
---|
229 | * {@link wjhk.jupload2.policies.UploadPolicy}</td> |
---|
230 | * <td>This parameter allows to control whether the file icons in the file |
---|
231 | * chooser are calculated from the file content. This is currently only |
---|
232 | * available for pictures.<BR> |
---|
233 | * If activated, the file chooser will open each pictures, and calculate the |
---|
234 | * icon by resizing the picture. This is done in by using thread of minimam |
---|
235 | * priority, to minimize performances impact on the navigator. Available values |
---|
236 | * are: <DIR> |
---|
237 | * <LI>-1: disabled. The default system are used. |
---|
238 | * <LI>0 (default): available only in picture mode. That is: the current upload |
---|
239 | * policy is an instance of or a class inheriting from |
---|
240 | * {@link PictureUploadPolicy} |
---|
241 | * <LI>1: available for all upload policies. </DIR></td> |
---|
242 | * </tr> |
---|
243 | * <tr> |
---|
244 | * <td>fileChooserIconSize</td> |
---|
245 | * <td><i>20</i><br> |
---|
246 | * since 3.1.0b<br> |
---|
247 | * {@link wjhk.jupload2.policies.UploadPolicy}</td> |
---|
248 | * <td>This parameter allows to control the size of icons, in pixels, in the |
---|
249 | * file chooser. Used only when fileChooserIconFromFileContent is activated.<BR> |
---|
250 | * Note: The standard icon size is a value of 20. With 50, you'll get a better |
---|
251 | * view of the picture.</td> |
---|
252 | * </tr> |
---|
253 | * <tr> |
---|
254 | * <td>fileChooserImagePreview</td> |
---|
255 | * <td><i>true</i><br> |
---|
256 | * since 3.1.0b<br> |
---|
257 | * {@link wjhk.jupload2.policies.PictureUploadPolicy}</td> |
---|
258 | * <td>This parameter allows to control whether an preview is available for |
---|
259 | * picture in the file chooser. If activated, the file chooser will open the |
---|
260 | * preview in a separate thread, of high priority. This avoid blocking the |
---|
261 | * applet while calculating the preview picture, when the user just |
---|
262 | * double-clicked a picture file. This parameter is ignored for |
---|
263 | * DefaultUploadPolicy. |
---|
264 | * </tr> |
---|
265 | * <tr> |
---|
266 | * <tr> |
---|
267 | * <td>fileFilterName</td> |
---|
268 | * <td><i>null</i><br> |
---|
269 | * since 5.0.0</td> |
---|
270 | * Contains the name of the file filter, as it will be displayed in the drop |
---|
271 | * down list of filters, in the file chooser. If this name is given to the |
---|
272 | * applet, it will be returned by the {@link FileFilter#getDescription()} |
---|
273 | * method. <BR> |
---|
274 | * Default value for applet parameter "fileFilterName". This default value let |
---|
275 | * the {@link DefaultUploadPolicy} return a calculated name, which contains the |
---|
276 | * list of allowed file extensions.<BR> |
---|
277 | * Note: this parameter is ignored, if there is no file filter, that is, if the |
---|
278 | * allowedFileExtensions applet parameter is not used. |
---|
279 | * <td> |
---|
280 | * </tr> |
---|
281 | * <tr> |
---|
282 | * <td><s>filenameEncoding</s></td> |
---|
283 | * <td><S><i>null</i></S><br> |
---|
284 | * <br> |
---|
285 | * <S>{@link wjhk.jupload2.policies.DefaultUploadPolicy}</S></td> |
---|
286 | * <td>Since 3.3.0, this parameter is no more used. The full applet upload HTTP |
---|
287 | * request to the server is now correctly encoded.<BR> |
---|
288 | * <S>With null, the filename in the <i>Content-Disposition</i> header is not |
---|
289 | * encoded. If not null, the applet tries to encode this filename with the given |
---|
290 | * encoding. It's up to the receiver (the web site) to decode this encoding (see |
---|
291 | * {@link #getUploadFilename(FileData, int)}. <br> |
---|
292 | * Example: if the "UTF8" encoding is chosen, the PHP function urldecode can be |
---|
293 | * used to decode the filename. </S></td> |
---|
294 | * </tr> |
---|
295 | * <tr> |
---|
296 | * <tr> |
---|
297 | * <td>formdata</td> |
---|
298 | * <td><i>null</i><br> |
---|
299 | * <br> |
---|
300 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}<br> |
---|
301 | * <i>Since 2.9.2rc4</i></td> |
---|
302 | * <td>With this parameter, the name of a HTML form can be specified. If the |
---|
303 | * specified form exists in the same document like the applet, all all |
---|
304 | * form-variables are added as POST parameters to the applet's POST request.<BR> |
---|
305 | * <B>Note:</B> Whatever value is in the <U>httpUploadParameterType</U> applet |
---|
306 | * parameter, these parameters with the name of the given input in the form. |
---|
307 | * That is: if you have an input text named 'myText', there will be one myText |
---|
308 | * parameter in the HTTP upload request, with the text/plain mime type, and |
---|
309 | * whose value is the content of this field, in the form.</td> |
---|
310 | * </tr> |
---|
311 | * <tr> |
---|
312 | * <td>ftpCreateDirectoryStructure</td> |
---|
313 | * <td><i>false</i><br> |
---|
314 | * since 4.2.0<br> |
---|
315 | * {@link wjhk.jupload2.policies.UploadPolicy}</td> |
---|
316 | * <td>This parameter allows to control whether the directory structure on the |
---|
317 | * client side must be created on the server side.<BR> |
---|
318 | * Example: if the user upload the test/ directory, which contains the |
---|
319 | * readme.txt file. With <I>ftpCreateDirectoryStructure</I> to false (or default |
---|
320 | * value), the readme.txt is uploaded in the postURL directory. If set to true, |
---|
321 | * the test/ folder is created as a subfolder of the path given in the postURL |
---|
322 | * directory, and the readme.txt is uploaded in this subfolder.<BR> |
---|
323 | * Note: in HTTP upload, the pathinfo and relpathinfo allows the server side |
---|
324 | * script to manage this directory structure.</td> |
---|
325 | * </tr> |
---|
326 | * <tr> |
---|
327 | * <td>ftpTransfertBinary</td> |
---|
328 | * <td><i>true</i><br> |
---|
329 | * since 4.1.0<br> |
---|
330 | * {@link wjhk.jupload2.policies.UploadPolicy}</td> |
---|
331 | * <td>This parameter allows to control whether the upload should be done in |
---|
332 | * binary or ascii mode. Default is to upload in binary mode.</td> |
---|
333 | * </tr> |
---|
334 | * <tr> |
---|
335 | * <td>ftpTransfertPassive</td> |
---|
336 | * <td><i>true</i><br> |
---|
337 | * since 4.1.0<br> |
---|
338 | * {@link wjhk.jupload2.policies.UploadPolicy}</td> |
---|
339 | * <td>This parameter allows to control whether the upload should be done in FTP |
---|
340 | * passive mode, or in active mode (where the FTP server opens a connection to |
---|
341 | * the client, to do the upload). Default passive mode.</td> |
---|
342 | * </tr> |
---|
343 | * <tr> |
---|
344 | * <td>highQualityPreview</td> |
---|
345 | * <td>false<br> |
---|
346 | * <br> |
---|
347 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
348 | * <td>If this parameter is set to <i>true</i>, the applet will call the |
---|
349 | * BufferedImage.getScaledInstance(), instead of doing a basic scale |
---|
350 | * transformation. This consume more CPU: on a PII 500MHz, the full screen go |
---|
351 | * from around 5 seconds to between 12 and 20 seconds, for a picture created by |
---|
352 | * my EOS20D (8,5M pixels). The standard preview (above the file list) seem to |
---|
353 | * be displayed at the same speed, whatever is the value of this parameter. <br> |
---|
354 | * Note: when resizing is done before upload, the |
---|
355 | * BufferedImage.getScaledInstance() is always called, so that the uploaded |
---|
356 | * picture is of the best available quality.</td> |
---|
357 | * </tr> |
---|
358 | * <tr> |
---|
359 | * <td>httpUploadParameterName</td> |
---|
360 | * <td>File<br> |
---|
361 | * <br> |
---|
362 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}<BR> |
---|
363 | * since 4.5.0</td> |
---|
364 | * <td>Contains the parameter name, that will be used to send the file in the |
---|
365 | * HTTP upload request. The default value (File), associated with the default |
---|
366 | * value for httpUploadParameterType (see below), makes all file be uploaded |
---|
367 | * with name from File0 to FileN (when there are N+1 file to upload).<BR> |
---|
368 | * Put another value, of your server part script need a particular parameter |
---|
369 | * name to work properly.<BR> |
---|
370 | * Note: valid characters for this parameter are: first letter (letter or |
---|
371 | * number), next letters (letter, number or underscore)</td> |
---|
372 | * </tr> |
---|
373 | * <tr> |
---|
374 | * <td>httpUploadParameterType</td> |
---|
375 | * <td>iteration<br> |
---|
376 | * <br> |
---|
377 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}<BR> |
---|
378 | * since 4.5.0</td> |
---|
379 | * <td>Allowed values are: <DIR> |
---|
380 | * <LI><B>iteration</B>: Used to have the attribute property that actually |
---|
381 | * contains the file be named File0 to FileN (if you have N+1 uploaded files). |
---|
382 | * This is the default behavior. In this case, your server script should look |
---|
383 | * for POST properties, named 'File0' to 'FileN'</LI> |
---|
384 | * <LI><B>array</B>: Used if your server script want to receive one array, that |
---|
385 | * will contain all uploaded files.</LI> |
---|
386 | * <LI><B>oneFile</B>: Indicates that, in the HTTP upload request, there will be |
---|
387 | * only one file. This value is only valid when nbFilesPerRequest is 1. The |
---|
388 | * parameters in the HTTP upload request are let untransformed. For instance, if |
---|
389 | * httpUploadParameterName is the default value (File), the file content will be |
---|
390 | * loaded under the HTTP parameter 'File' (not File0 or File[]).</LI></DIR><BR> |
---|
391 | * <B>Note:</B> All parameters common to all pictures are sent directly. For |
---|
392 | * instance, if toto is given on the URL, the toto parameter is sent as is (no |
---|
393 | * toto0 for iteration or toto[] for array). Also, if you use the |
---|
394 | * <U>formdata</U> applet parameter, these parameters are sent as is (no 0 or [] |
---|
395 | * added to the parameter name).</td> |
---|
396 | * </tr> |
---|
397 | * <tr> |
---|
398 | * <td>keepOriginalFileExtensionForConvertedImages</td> |
---|
399 | * <td><i>false</i></td> |
---|
400 | * <td>is only relevant, if targetPictureFormat is specified.<br /> |
---|
401 | * <ul> |
---|
402 | * <li>false (default): <br /> |
---|
403 | * If you upload the file 'test.png' and it is converted to 'jpg', the |
---|
404 | * fileextension will be changed, so that the server will receive this filename: |
---|
405 | * 'test.jpg'</li> |
---|
406 | * <li>true: <br /> |
---|
407 | * If you upload the file 'test.png' and it is converted to 'jpg', the |
---|
408 | * fileextension will NOT be changed, so that the server will receive the |
---|
409 | * original filename: 'test.png'</li> |
---|
410 | * </ul> |
---|
411 | * </td> |
---|
412 | * </tr> |
---|
413 | * <tr> |
---|
414 | * <td>lang</td> |
---|
415 | * <td>Navigator language <br> |
---|
416 | * <br> |
---|
417 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
418 | * <td>Should be something like <i>en</i>, <i>fr</i>... Currently only French |
---|
419 | * and English are known from the applet. If anyone want to add another language |
---|
420 | * ... Please translate the wjhk.jupload2.lang.lang_en, and send it back to |
---|
421 | * <mailto:etienne_sf@sourceforge.net">.</td> |
---|
422 | * </tr> |
---|
423 | * <tr> |
---|
424 | * <td>lookAndFeel <br> |
---|
425 | * since 2.5</td> |
---|
426 | * <td><i>empty</i><br> |
---|
427 | * <br> |
---|
428 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
429 | * <td>This allows to control the look & feel of the applet. The authorized |
---|
430 | * values are: |
---|
431 | * <ul> |
---|
432 | * <li><i>empty</i>: uses the default look & feel. This is the same as java. |
---|
433 | * <li>java: uses the java default look & feel. Same as <i>empty</i>. |
---|
434 | * <li>system: uses the current system look and feel. The call will be : <br> |
---|
435 | * UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); |
---|
436 | * <li>Any valid String argument for UIManager.setLookAndFeel(String). |
---|
437 | * </ul> |
---|
438 | * </td> |
---|
439 | * </tr> |
---|
440 | * <tr> |
---|
441 | * <td>maxChunkSize<br> |
---|
442 | * Since 2.7.1</td> |
---|
443 | * <td>0<br> |
---|
444 | * <i>Long.MAX_VALUE</i><br> |
---|
445 | * <br> |
---|
446 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
447 | * <td>This parameters defines the maximum size of an upload. |
---|
448 | * <ul> |
---|
449 | * <li>If not set, or set to a value of 0 or less, the chunk mode is disabled. |
---|
450 | * That is: each file will be uploaded within being split in pieces. |
---|
451 | * <li>If set to a value of 1 or more, the upload size will be never be more |
---|
452 | * than maxChunkSize. A file bigger will be split in several part of |
---|
453 | * <i>maxChunkSize</i> size, then the last part will contain the remaining, and |
---|
454 | * will probably be smaller than <i>maxChunkSize</i>. |
---|
455 | * </ul> |
---|
456 | * <br> |
---|
457 | * <b>How to build the server part:</b> the server will have to 'guess' that the |
---|
458 | * file is split, and then it will have to reconstruct the uploaded file. Here |
---|
459 | * are the necessary informations: |
---|
460 | * <ul> |
---|
461 | * <li>When a file is chunked, the <i>jupart</i> and <i>jufinal</i> parameter |
---|
462 | * are given in the URL (get parameters). This identify a chunk upload. If these |
---|
463 | * parameters are not given, the file(s) is(are) uploaded in one piece. |
---|
464 | * <li><i>jupart</i> identify the part number: from 1 to N for a file being |
---|
465 | * split in N pieces. The N-1 chunks should be <i>maxChunkSize</i> bytes long. |
---|
466 | * The last one contains the remaining of the file. |
---|
467 | * <li><i>jufinal</i> is set to 0 for chunks from 1 to N-1. It is is set to 1 |
---|
468 | * only for the last chunk (N, in this 'example'). |
---|
469 | * <li>The uploaded filename is not modified when the upload is chunked. |
---|
470 | * Example: upload of the file <i>bigPicture.jpeg</i>, of 4,5 Mb, with chunk of |
---|
471 | * 2Mb. The upload is split in three chunk. Chunk 1 and 2 are 2Mb long. The |
---|
472 | * third one is 0,5Mb long. The uploaded filename for these three uploads is |
---|
473 | * <i>bigPicture.jpeg</i>. It's up to the server part to read the <i>jupart</i> |
---|
474 | * and <i>jufinal</i> get parameters, to understand that the upload is chunked. |
---|
475 | * <li><b>Important:</b> The server script <u>must</u> check the resulting |
---|
476 | * filesize. If not, the client can send a file of any size, and fill the server |
---|
477 | * hard drive. |
---|
478 | * <li>The wwwroot/pages/parseRequest.jsp is a java example of a server page |
---|
479 | * that can receive chunk upload. It stores each chunk is <i>filename.partN</i> |
---|
480 | * (where N is the chunk number), then construct the final file, by |
---|
481 | * concatenating all parts together. |
---|
482 | * </ul> |
---|
483 | * <b>Note: </b> If nbFilesPerRequest is different than 1, the applet will try |
---|
484 | * to upload the files until the sum of their content length is less than |
---|
485 | * maxChunkSize. The upload is triggered just before the sum of their content |
---|
486 | * length is bigger then maxChunkSize.<br> |
---|
487 | * If one file is bigger than <i>maxChunkSize</i>, all previous files are |
---|
488 | * uploaded (at once or not, depending on nbFilesPerRequest). Then the 'big' |
---|
489 | * file is uploaded alone, split in chunk. Then upload goes on, file by file or |
---|
490 | * not, depending on <i>nbFilesPerRequest</i>.</td> |
---|
491 | * </tr> |
---|
492 | * <tr> |
---|
493 | * <td>maxFileSize<br> |
---|
494 | * Since 2.7.1</td> |
---|
495 | * <td>0<br> |
---|
496 | * <i>Long.MAX_VALUE</i><br> |
---|
497 | * <br> |
---|
498 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
499 | * <td>This parameter identify the maximum size that an uploaded file may have. |
---|
500 | * It prevent the user to upload too big files. It is especially important when |
---|
501 | * chunk upload is activated (see below <i>maxChunkSize</i>). |
---|
502 | * <ul> |
---|
503 | * <li>If <i>maxChunkSize</i> is not set, negative or 0, <i>maxFileSize</i> |
---|
504 | * should be the maximum upload size of the server. In this case, it is useful |
---|
505 | * only to display a message when the user select a file that will be refused by |
---|
506 | * the server. |
---|
507 | * <li>If chunk upload is activated, this parameter becomes really important: in |
---|
508 | * this case the maximum file size of an uploaded file is ... the available |
---|
509 | * space on the server hard drive! (see below, <i>maxChunkSize</i>). |
---|
510 | * </ul> |
---|
511 | * </td> |
---|
512 | * </tr> |
---|
513 | * <tr> |
---|
514 | * <td>maxPicHeight</td> |
---|
515 | * <td>Since 3.3.0: Integer.MAX_VALUE<BR> |
---|
516 | * (was -1)<br> |
---|
517 | * <br> |
---|
518 | * {@link wjhk.jupload2.policies.PictureUploadPolicy}</td> |
---|
519 | * <td>This parameters allows the HTML page to control the maximum height for |
---|
520 | * pictures. If a picture is to be download, and its height is bigger, the |
---|
521 | * picture will be resized. The proportion between width and height of the |
---|
522 | * resized picture are the same as those of the original picture. If both |
---|
523 | * maxPicHeight and maxPicWidth are given, it can happen that the resized |
---|
524 | * picture has a height lesser than maxPicHeight, so that width is no more than |
---|
525 | * maxPicWidth. <br> |
---|
526 | * <b>Precisions:</b> <br> |
---|
527 | * If this parameter value is negative or 0, then no control is done on the |
---|
528 | * picture height. <br> |
---|
529 | * If the original picture is smaller than the maximum size, the picture is not |
---|
530 | * enlarged. <br> |
---|
531 | * If the picture is resized, its other characteristics are kept (number of |
---|
532 | * colors, ColorModel...). The picture format is kept, if targetPictureFormat is |
---|
533 | * empty. If the picture format is a destructive (like jpeg), the maximum |
---|
534 | * available quality is chosen. <br> |
---|
535 | * <i>See also maxPicWidth, realMaxPicHeight</i></td> |
---|
536 | * </tr> |
---|
537 | * <tr> |
---|
538 | * <td>maxPicWidth</td> |
---|
539 | * <td>Since 3.3.0: Integer.MAX_VALUE<BR> |
---|
540 | * (was -1)<br> |
---|
541 | * <br> |
---|
542 | * {@link wjhk.jupload2.policies.PictureUploadPolicy}</td> |
---|
543 | * <td>Same as maxPicHeight, but for the maximum width of the uploaded picture. |
---|
544 | * <br> |
---|
545 | * <i>See also maxPicHeight, realMaxPicWidth</i></td> |
---|
546 | * </tr> |
---|
547 | * <tr> |
---|
548 | * <td>nbFilesPerRequest</td> |
---|
549 | * <td>1 since 4.3.0 <BR> |
---|
550 | * (was -1) <br> |
---|
551 | * <br> |
---|
552 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
553 | * <td>This allows the control of the maximal number of files that are uploaded |
---|
554 | * in one HTTP upload to the server. <br> |
---|
555 | * If set to less than 1 (0 or negative), there is no maximum. This means that all files are uploaded in |
---|
556 | * the same HTTP request. <br> |
---|
557 | * If set to 5, for instance, and there are 6 files to upload, there will be two |
---|
558 | * HTTP upload request to the server : 5 files in the first one, and that last |
---|
559 | * file in a second HTTP request.</td> |
---|
560 | * </tr> |
---|
561 | * <tr> |
---|
562 | * <td>pictureCompressionQuality</td> |
---|
563 | * <td><i>0.8</i><br> |
---|
564 | * since 3.1.0<br> |
---|
565 | * {@link wjhk.jupload2.policies.PictureUploadPolicy}</td> |
---|
566 | * <td>This parameter controls the picture compression quality, when writing the |
---|
567 | * picture file. 1 means high quality picture, but big files. 0 means poor |
---|
568 | * quality pictures, but small files. 0.8 is a good compromise for the web.<br> |
---|
569 | * It is different from the highQualityPreview, which controls the way picture |
---|
570 | * are resized in memory.<br> |
---|
571 | * This parameter is currently applied only to jpg (and jpeg) pictures.</td> |
---|
572 | * </tr> |
---|
573 | * <tr> |
---|
574 | * <td>pictureTransmitMetadata</td> |
---|
575 | * <td><i>false since 3.3.0<br> |
---|
576 | * (was true before)</i><br> |
---|
577 | * since 3.2.0<br> |
---|
578 | * {@link wjhk.jupload2.policies.PictureUploadPolicy}</td> |
---|
579 | * <td>This parameter controls whether the applet transmit metadata of the |
---|
580 | * original picture. This may prevent personal information to be thrown on the |
---|
581 | * net.<br> |
---|
582 | * Note 1: This parameter is especially important for picture coming from the |
---|
583 | * Canon EOS 20D, 30D and 40D: pictures shooted in portrait mode contain |
---|
584 | * metadata that are incompatible with Java 1.6.0_3! The colors of transformed |
---|
585 | * pictures become strange... <B>Since 3.3.0: default to false</B>, to avoid |
---|
586 | * this annonying (and currently not explained) problem.<br> |
---|
587 | * Note 2: <Caution> As of 3.2.0, this parameter blocks metadata only for |
---|
588 | * pictures that are updated by the applet. Metadata from picture transmitted |
---|
589 | * 'as is' are not removed. This is corrected in 3.3.0.</td> |
---|
590 | * </tr> |
---|
591 | * <tr> |
---|
592 | * <td>postURL</td> |
---|
593 | * <td>null since 1.9.2rc4, (was <i>Mandatory</i> before)<br> |
---|
594 | * <br> |
---|
595 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
596 | * <td>This parameter specifies the target URL toward which the files should be |
---|
597 | * uploaded. Since version 1.9.2rc4 this parameter is not mandatory anymore. |
---|
598 | * Instead, if omitted or a <i>relative</i> URL is given, the resulting URL is |
---|
599 | * constructed from the applet's DocumentBaseURL. This means, that if the applet |
---|
600 | * tag is dynamically constructed from a PHP script without specifying |
---|
601 | * <code>postURL</code>, the <i>same</i> same script receives the subsequent |
---|
602 | * POST request(s). If this URL may change during the applet execution time, you |
---|
603 | * can call the setProperty applet method from javascript, or create a new |
---|
604 | * UploadPolicy class and either : |
---|
605 | * <ul> |
---|
606 | * <li>Override the {@link wjhk.jupload2.policies.UploadPolicy#getPostURL()} |
---|
607 | * method, to make the postURL totaly dynamic. |
---|
608 | * <li>Override the |
---|
609 | * {@link wjhk.jupload2.policies.UploadPolicy#setPostURL(String)} method, to |
---|
610 | * modify the postURL on the fly, when it is changed. |
---|
611 | * <li>Override the |
---|
612 | * {@link wjhk.jupload2.policies.UploadPolicy#setProperty(String, String)} |
---|
613 | * method. The {@link wjhk.jupload2.policies.CoppermineUploadPolicy} changes the |
---|
614 | * postURL when the albumID property changes. |
---|
615 | * <li>Find another solution ... |
---|
616 | * </ul> |
---|
617 | * <u>Note 1:</u> in HTTP, the upload is done in the same user session, as the |
---|
618 | * applet uses the cookies from the navigator. This allows right management |
---|
619 | * during upload, on the server side.<br> |
---|
620 | * <u>Note 2:</u> in FTP, you can't use path that contain spaces. Filename may |
---|
621 | * contain spaces. <u>Note 5:</u> in HTTP, the applet use the current Java |
---|
622 | * parameter to connect to the host. By default, this configuration is to use |
---|
623 | * the navigator configuration. So, if a proxy is configured in the navigator |
---|
624 | * network configuration, the applet should use it automatically.<br> |
---|
625 | * <u>Note 3:</u> FTP URL should looks like: |
---|
626 | * ftp://username:password@myhost.com:21/directory<br> |
---|
627 | * <u>Note 4:</u> in FTP, you'll have to add the jakarta-commons-oro.jar and |
---|
628 | * jakarta-commons-net.jar jar files in the applet ARCHIVE tag attribute. See |
---|
629 | * the 'advanced_js_demo.html page for a sample. You'll have to put the two |
---|
630 | * files coming from the JUpload distribution in the same directory as the |
---|
631 | * wjhk.jupload.jar. <br> |
---|
632 | * <u>Note 5:</u> in FTP, you can use the user default folder by putting no |
---|
633 | * folder. The URL can be: ftp://user:mdp@host</td> |
---|
634 | * <u>Note 6 (security):</u> take care that the full URL is visible, if the user |
---|
635 | * take a look at the page source. So, you should take care when putting login |
---|
636 | * and password there. </td> |
---|
637 | * </tr> |
---|
638 | * <tr> |
---|
639 | * <td>readCookieFromNavigator</td> |
---|
640 | * <td>Since 4.3.0: Boolean<BR> |
---|
641 | * (true)<br> |
---|
642 | * <br> |
---|
643 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}<br> |
---|
644 | * <i>Since v2.8.1</i></td> |
---|
645 | * <td>If true (default), the applet read cookies from the navigator, with the |
---|
646 | * javascript document.cookie value. If false, the caller should put the |
---|
647 | * relevant 'Cookie' header in the specificHeaders applet parameter. This allows |
---|
648 | * to override any javascript cookie access restriction.</td> |
---|
649 | * </tr> |
---|
650 | * <td>readUserAgentFromNavigator</td> |
---|
651 | * <td>Since 4.6.1rc2: Boolean<BR> |
---|
652 | * (true)<br> |
---|
653 | * <br> |
---|
654 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}<br> |
---|
655 | * </td> |
---|
656 | * <td>If true (default), the applet read the userAgent from the navigator, with |
---|
657 | * the javascript document.userAgent value. If false, the caller can put the |
---|
658 | * relevant userAgent header in the specificHeaders applet parameter.</td> </tr> |
---|
659 | * <tr> |
---|
660 | * <td>realMaxPicHeight</td> |
---|
661 | * <td>Since 3.3.0: Integer.MAX_VALUE<BR> |
---|
662 | * (was -1)<br> |
---|
663 | * <br> |
---|
664 | * {@link wjhk.jupload2.policies.PictureUploadPolicy}<br> |
---|
665 | * <i>Since v2.8.1</i></td> |
---|
666 | * <td>This parameters is about the same as maxPicHeight. It overrides it for |
---|
667 | * pictures that must be transformed (currentlty only when the picture is |
---|
668 | * rotated). <br> |
---|
669 | * The aim of this parameter, is to prevent the applet to resize picture, and |
---|
670 | * let the server do it: it will be much quicker. <br> |
---|
671 | * This allows you to: |
---|
672 | * <ul> |
---|
673 | * <li>Put a 'big' <i>maxPicHeight</i> (or don't provide the parameter in the |
---|
674 | * APPLET tag), and let the server resize the picture according to the real |
---|
675 | * maxPicHeight. The <i>maxPicHeight</i> will be used when the picture is not |
---|
676 | * tranformed by the user. |
---|
677 | * <li>Put this realMaxHeight to the real configured maxPicHeight. The applet |
---|
678 | * will then directly produce the final file, when it has to tranform the |
---|
679 | * picture (picture rotation, for instance). |
---|
680 | * </ul> |
---|
681 | * <br> |
---|
682 | * <i>See also maxPicHeight, realMaxPicWidth, maxChunkSize (to override any |
---|
683 | * server upload size limitation).</i></td> |
---|
684 | * </tr> |
---|
685 | * <tr> |
---|
686 | * <td>realMaxPicWidth</td> |
---|
687 | * <td>Since 3.3.0: Integer.MAX_VALUE<BR> |
---|
688 | * (was -1)<br> |
---|
689 | * <br> |
---|
690 | * {@link wjhk.jupload2.policies.PictureUploadPolicy}<br> |
---|
691 | * <i>Since v2.8.1</i></td> |
---|
692 | * <td>Same as realMaxPicHeight, but for the maximum width of uploaded picture |
---|
693 | * that must be transformed. <br> |
---|
694 | * <i>See also maxPicWidth, realMaxPicHeight</i></td> |
---|
695 | * </tr> |
---|
696 | * <tr> |
---|
697 | * <td>retryMaxNumberOf</td> |
---|
698 | * <td>1<BR> |
---|
699 | * <i>Since 5.0.0</i></td> |
---|
700 | * <td>Maximum number of retries, that the applet will do, for upload resumable |
---|
701 | * error. A 'upload resumable error', is typically a network error. The default |
---|
702 | * value is 0, to maintain the same behaviour as before.<BR> |
---|
703 | * This maximum of allowed retries is for each packet, that is: if one packet |
---|
704 | * fails two times, and succeed in the third attempt, the next packet will still |
---|
705 | * have up to retryMaxNumberOf retries. For instance, the default value (1), |
---|
706 | * means that the applet will do a one new attempt after a first upload error, |
---|
707 | * for each packet.</td> |
---|
708 | * </tr> |
---|
709 | * <tr> |
---|
710 | * <td>retryNbSecondsBetween</td> |
---|
711 | * <td>30<BR> |
---|
712 | * <i>Since 5.0.0</i></td> |
---|
713 | * <td>The number of seconds, to wait, before trying a new upload of a packet |
---|
714 | * whose upload was in error. This is used if <I>retryMaxNumberOf</I> is 1 or |
---|
715 | * more, and if 'resumable upload error' occurs.</td> |
---|
716 | * </tr> |
---|
717 | * <tr> |
---|
718 | * <td>serverProtocol</td> |
---|
719 | * <td>null since 2.9.2rc4<br> |
---|
720 | * (before: "HTTP/1.1")<br> |
---|
721 | * <br> |
---|
722 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
723 | * <td>This parameter allows the control of the protocol toward the server. It |
---|
724 | * can be HTTP/0.9 (not tested), HTTP/1.0, HTTP/1.1 and FTP. HTTP supports |
---|
725 | * https. Since version 2.9.2rc4, the default is <i>null</i>, introducing a new |
---|
726 | * facility of automatically adjusting the protocol according to the server |
---|
727 | * response.<br> |
---|
728 | * This parameter is really useful only in |
---|
729 | * {@link wjhk.jupload2.policies.CoppermineUploadPolicy}, as the coppermine |
---|
730 | * application also controls that the requests send within an HTTP session uses |
---|
731 | * the same HTTP protocol (as a protection to limit the 'steal' of session |
---|
732 | * cookies).</td> |
---|
733 | * </tr> |
---|
734 | * <tr> |
---|
735 | * <td>sendMD5Sum</td> |
---|
736 | * <td>false<BR> |
---|
737 | * since 5.0.0<br> |
---|
738 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
739 | * <td>This parameter indicates whether the applet will send the MD5Sum for |
---|
740 | * uploaded files, or not. If set to true, the MD5Sum is sent in the |
---|
741 | * <I>md5sum</I> HTTP POST argument.</td> |
---|
742 | * </tr> |
---|
743 | * <tr> |
---|
744 | * <td>showLogWindow<br> |
---|
745 | * Since 3.0.2<br> |
---|
746 | * Changed in 3.5.0</td> |
---|
747 | * <td>true<br> |
---|
748 | * <br> |
---|
749 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
750 | * <td>This parameter was formerly known as <i>showStatusBar</i> which now has a |
---|
751 | * different purpose. <BR> |
---|
752 | * <U>Since 3.5.0:</U> Available values are (case sensitive):<DIR> |
---|
753 | * <LI>true: always visible. |
---|
754 | * <LI>false: always hiden. |
---|
755 | * <LI>onError: the log window is hidden. It will be displayed when an error |
---|
756 | * occurs. If you put 99 into the debugLevel, then the full debugOutput become |
---|
757 | * visible if and only if an error occurs</DIR> <BR> |
---|
758 | * <U>Until 3.4.2</U>, it works this way: If given with the <i>False</i> value, |
---|
759 | * the log window will be hidden. The applet will still store all debug |
---|
760 | * information in it. But the user won't see it any more. If a problem occurs, |
---|
761 | * the <i>urlToSendErrorTo</i> can still be used to log all available |
---|
762 | * information.</td> |
---|
763 | * </tr> |
---|
764 | * <tr> |
---|
765 | * <td>showStatusBar</td> |
---|
766 | * <td>True<br> |
---|
767 | * <br> |
---|
768 | * New meaning since 3.0.2<br> |
---|
769 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
770 | * <td>This parameter controls if the status bar is shown in the applet. If |
---|
771 | * shown, the stausbar provides information about the current transfer speed and |
---|
772 | * estimated time of completion. Before version 3.0.2, this parameter was used |
---|
773 | * to control visibility of the log window. This is now controlled by |
---|
774 | * <i>showLogWindow</i>.</td> |
---|
775 | * </tr> |
---|
776 | * <tr> |
---|
777 | * <td>specificHeaders</td> |
---|
778 | * <td><I>null</I><br> |
---|
779 | * <br> |
---|
780 | * Since 3.0.2<br> |
---|
781 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
782 | * <td>Allows the caller to add any header(s) to the applet. These headers will |
---|
783 | * be sent with each HTTP request to the server. If you put several lines in |
---|
784 | * this parameter, these parameter should be separated by the "\n" string |
---|
785 | * (not the LineFeed character, but the antislash character followed by the n |
---|
786 | * character, like msg="\\n";). No "\n" at the end: it will be added |
---|
787 | * by the applet. In PHP, put '\n', and not "\n" (See PHP doc, on |
---|
788 | * strings)<BR> |
---|
789 | * This allows an easy management of <B>Basic HTTP authentication</B>. Just add |
---|
790 | * a header like this one:<BR> |
---|
791 | * Authorization: Basic Base64EncodedString Where Base64EncodedString is the |
---|
792 | * string "login:passord" encoded in Base 64.</td> |
---|
793 | * </tr> |
---|
794 | * <tr> |
---|
795 | * <td>sslVerifyCert<br> |
---|
796 | * Since 3.0.2b1</td> |
---|
797 | * <td>none<br> |
---|
798 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
799 | * <td>With this parameter, the handling of certificates when using SSL can be |
---|
800 | * configured. There are 4 possible settings:<br> |
---|
801 | * <ul> |
---|
802 | * <li><i>none</i> (default): Any server cert is accepted, no cert-based client |
---|
803 | * authentication is performed.</li> |
---|
804 | * <li><i>server</i>: The server cert is verified against the local truststore |
---|
805 | * and if that fails, a dialog pops up which asks the user if the certificate |
---|
806 | * shall be accepted permanently, just for the current session or not at all |
---|
807 | * (Just like any browser would do).</li> |
---|
808 | * <li><i>client</i>: A user-certificate (which must be available in the local |
---|
809 | * keystore) is used to perform client authentication.</li> |
---|
810 | * <li><i>strict</i>: The combination of <i>client</i> and <i>server</i>.</li> |
---|
811 | * </ul> |
---|
812 | * <p> |
---|
813 | * The location of the local truststore and keystore uses the normal JRE |
---|
814 | * conventions. This means, that the system truststore is used for verifying |
---|
815 | * server certs (usually in $JAVA_HOME/lib/security/cacerts) unless either the |
---|
816 | * system property <i>javax.net.ssl.trusStore</i> specifies another location or |
---|
817 | * a file <b>.truststore</b> exists in the user's home directory. If the user |
---|
818 | * decides to permanently accept an untrusted certificate, the file |
---|
819 | * <b>.truststore</b> in the user's home directory is written. The default |
---|
820 | * keystore (for client certificates) is the file <b>.keystore</b> in the user's |
---|
821 | * home directory. This can be overridden by setting the system property |
---|
822 | * <i>javax.net.ssl.keyStore</i>. If the name of the keystore ends in |
---|
823 | * <b>.p12</b>, it is assumed that the keystore is in <b>PKCS12</b> format, |
---|
824 | * otherwise the default format as specified in the JRE security-configuration |
---|
825 | * is used. |
---|
826 | * <p> |
---|
827 | * <b>Important Note about client authentication:</b> |
---|
828 | * <p> |
---|
829 | * At the time of this writing, a <i>serious</i> bug exists in apache 2.0.x |
---|
830 | * which prevents POST requests when SSL renegotiation is about to happen. |
---|
831 | * Renegotiation is triggered by a location-based (or directory-based) change of |
---|
832 | * the SSLVerifyClient directive in apache. Therefore you <b>can not</b> protect |
---|
833 | * a sub-area of an otherwise unprotected SSL server. You can circumvent that by |
---|
834 | * setting up a virtualhost which is configured to perform SSL client |
---|
835 | * verification <b>for the complete virtualhost</b>. Attached to the bug report |
---|
836 | * at <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=12355">ASF |
---|
837 | * Bugzilla</a>, there are several patches which claim to fix the problem. |
---|
838 | * However in that same report, other users complain about those patches to be |
---|
839 | * ineffective. Therefore, the author recommends avoiding re-negotiation |
---|
840 | * alltogether by using the virtualhost aproach described above. It is the |
---|
841 | * understanding of the author, that this bug has been fixed for apache 2.2, |
---|
842 | * however the author did not verify that. Test-Reports from users running |
---|
843 | * apache 2.2 are welcome. |
---|
844 | * </td> |
---|
845 | * </tr> |
---|
846 | * <tr> |
---|
847 | * <td>storeBufferedImage</td> |
---|
848 | * <td>false <br> |
---|
849 | * <I>Deprecated</I> <br> |
---|
850 | * {@link wjhk.jupload2.policies.PictureUploadPolicy}</td> |
---|
851 | * <td>This parameter indicates that the preview image on the applet is kept in |
---|
852 | * memory. It works really nice under eclise. But, once in the navigator, the |
---|
853 | * applet runs very quickly out of memory. So I add a lot of calls to |
---|
854 | * {@link wjhk.jupload2.filedata.PictureFileData#freeMemory(String, UploadPolicy)} |
---|
855 | * , but it doesn't change anything. Be careful to this parameter, and let it to |
---|
856 | * the default value, unless you've well tested it under all your target client |
---|
857 | * configurations. <BR> |
---|
858 | * <I>This parameter will probably never be correctly implemented.</I></td> |
---|
859 | * </tr> |
---|
860 | * <tr> |
---|
861 | * <td>stringUploadError</td> |
---|
862 | * <td>Since 3.2.0: "^ERROR: (.*)$" for all upload policies<br> |
---|
863 | * Empty string ("") [if using DefaultUploadPolicy]<br> |
---|
864 | * "ERROR: (.*)" [if using CopperminUploadPolicy]<br> |
---|
865 | * <br> |
---|
866 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}<br> |
---|
867 | * Since 2.9.2rc4</td> |
---|
868 | * <td>This string is a regular expression. It allows the applet to test that |
---|
869 | * the server has detected an error in the upload. If this parameter is given to |
---|
870 | * the applet, the upload thread will try to match this regular expression |
---|
871 | * against each line of the server response <b>body</b>. If a group is found, it |
---|
872 | * is considered as the error message, and will be displayed to the user.<br> |
---|
873 | * If the match is successfull once, the upload is considered to have failed. |
---|
874 | * and {@link wjhk.jupload2.exception.JUploadExceptionUploadFailed} is thrown. |
---|
875 | * If the expression contains a hunt-group, the matching contents of that group |
---|
876 | * is reported to the user. For example: If let the default value "^ERROR: |
---|
877 | * (.*)$" here, the applet will find an error if at least one line returned in |
---|
878 | * the server response begins with "ERROR: ". Then, all characters that follow |
---|
879 | * are extracted as the error message. So, if the server response contains the |
---|
880 | * line "ERROR: md5sum check failed", the string "md5sum check failed" is used |
---|
881 | * for the exception message. But if it returns a line "maybe ERROR: is it an |
---|
882 | * error?", then the applet won't find any error in the server response. <BR> |
---|
883 | * <B>Note:</B> you can put line breaks in the error message. The message must |
---|
884 | * be in one line in the HTTP response. To display a line break to the user, |
---|
885 | * just put the two characters \n in the http response (would be a "\\n" in java |
---|
886 | * or PHP).</td> |
---|
887 | * </tr> |
---|
888 | * <tr> |
---|
889 | * <td>stringUploadSuccess</td> |
---|
890 | * <td>"^SUCCESS$"<br> |
---|
891 | * empty string ("") since 2.9.0<br> |
---|
892 | * (was ".* 200 OK$" before) <br> |
---|
893 | * <br> |
---|
894 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
895 | * <td>This string is a regular expression. It allows the applet to test that |
---|
896 | * the server has accepted the upload. If this parameter is given to the applet, |
---|
897 | * the upload thread will try to match this regular expression against each |
---|
898 | * lines returned from the server.<br> |
---|
899 | * If the match is successfull once, the upload is considered to be a success. |
---|
900 | * If not, a {@link wjhk.jupload2.exception.JUploadExceptionUploadFailed} is |
---|
901 | * thrown. <br> |
---|
902 | * The default test expression testes that the web server returns no HTTP error: |
---|
903 | * 200 is the return code for a successfull HTTP request. It actually means that |
---|
904 | * postURL is a valid URL, and that the applet was able to send a request to |
---|
905 | * this URL: there should be no problem with the network configuration, like |
---|
906 | * proxy, password proxy...). <br> |
---|
907 | * <b>But</b> it doesn't mean that the uploaded files have correctly be managed |
---|
908 | * by the server. For instance, the URL can be http://sourceforge.net, which, of |
---|
909 | * course, would not take your files into account. <br> |
---|
910 | * So, as soon as you know a regular expression that test the return from the |
---|
911 | * target application (and not just a techical HTTP response code), change the |
---|
912 | * stringUploadSuccess to this value. For instance, the default value will be |
---|
913 | * matched if the HTTP body content of the server response contains one line |
---|
914 | * that is exactly 'SUCCESS', without any other character. This 'success' means |
---|
915 | * that the pictures have correctly uploaded to the server, and that he |
---|
916 | * successfully managed the uploaded files.</td> |
---|
917 | * </tr> |
---|
918 | * <tr> |
---|
919 | * <td>stringUploadWarning</td> |
---|
920 | * <td>"^WARNING: (.*)$" <br> |
---|
921 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}<br> |
---|
922 | * Since 3.4.2</td> |
---|
923 | * <td>This string is a regular expression. It allows the applet to test that |
---|
924 | * the server has detected a warning was generated by the server. This warning |
---|
925 | * is just a warning, that will be displayed to the user, as is. There may be |
---|
926 | * several warnings in the server return. If one or more warning is/are |
---|
927 | * received, the message(s) will be displayed to the user.<BR> |
---|
928 | * If the expression contains a hunt-group, the matching contents of that group |
---|
929 | * is reported to the user. For example: If you let the default value "^WARNING: |
---|
930 | * (.*)$" here, the applet will find an error if at least one line returned in |
---|
931 | * the server response begins with "WARNING: ". Then, all characters that follow |
---|
932 | * are extracted as the error message. So, if the server response contains the |
---|
933 | * line "WARNING: Bad encoding", the string "Bad encoding" is displayed as |
---|
934 | * warning message to the user. But if it returns a line "maybe WARNING: is it |
---|
935 | * an error?", then the applet won't find any warning in the server response.<BR> |
---|
936 | * <B>Notes:</B> <DIR> |
---|
937 | * <LI>There is no link between these warning and the fact the upload is |
---|
938 | * considered to be a success or not. Upload success is only based on the |
---|
939 | * success and error string. See the <B>stringUploadSuccess</B> and |
---|
940 | * <B>stringUploadError</B> applet parameters, here above. |
---|
941 | * <LI>You can put line breaks in the error message. The message must be in one |
---|
942 | * line in the HTTP response. To display a line break to the user, just put the |
---|
943 | * two characters \n in the http response (would be a "\\n" in java or PHP). |
---|
944 | * </DIR></td> |
---|
945 | * </tr> |
---|
946 | * <tr> |
---|
947 | * <td>targetPictureFormat</td> |
---|
948 | * <td><i>Empty String</i><br /> |
---|
949 | * {@link wjhk.jupload2.policies.PictureUploadPolicy}</td> |
---|
950 | * <td>This parameter can contain a list to convert image formats |
---|
951 | * <p> |
---|
952 | * Example 1:{@code "png,bmp:jpg;gif:png;"} |
---|
953 | * <ul> |
---|
954 | * <li>both png and bmp files will be converted to jpg,</li> |
---|
955 | * <li>gif files will be converted to png</li> |
---|
956 | * </ul> |
---|
957 | * Example 2:{@code "jpeg,jpg:png;"} |
---|
958 | * <ul> |
---|
959 | * <li>both jpeg and jpg files will be converted to png,</li> |
---|
960 | * </ul> |
---|
961 | * </p> |
---|
962 | * the value is expected to be a semi-colon separated list of relations from |
---|
963 | * source-format(s) to a target format.<br /> |
---|
964 | * format: <code>{SOURCEFORMAT{,SOURCEFORMAT*}:TARGETFORMAT;}*</code> |
---|
965 | * <ul> |
---|
966 | * <li>formats can contain any picture writer known by the JVM. For instance: |
---|
967 | * jpeg, png, gif. All standard formats should be available. More information |
---|
968 | * can be found on the <a |
---|
969 | * href="http://java.sun.com/j2se/1.4.2/docs/guide/imageio/spec/title.fm.html" |
---|
970 | * >java.sun.com</a> web site. |
---|
971 | * <li>SOURCEFORMAT: the source format that should be converted to the |
---|
972 | * TARGETFORMAT<br /> |
---|
973 | * e.g. png, jpg, jpeg, ..</li> |
---|
974 | * <li>TARGETFORMAT: the target format that all given SOURCEFORMAT should be |
---|
975 | * converted to <br /> |
---|
976 | * e.g. png, jpg, jpeg, ..</li> |
---|
977 | * <li>all format strings are case insensitive, so all following strings are the |
---|
978 | * same: |
---|
979 | * <ul> |
---|
980 | * <li><code>"jpeg,jpg:png;"</code></li> |
---|
981 | * <li><code>"JPEG,JPG:PNG;"</code></li> |
---|
982 | * <li><code>"jPeG,JpG:pNg;"</code></li> |
---|
983 | * </ul> |
---|
984 | * </li> |
---|
985 | * </ul> |
---|
986 | * notes: |
---|
987 | * <ul> |
---|
988 | * <li>animated gifs will not be converted</li> |
---|
989 | * <li>jpg and jpeg are distinct types.</li> |
---|
990 | * <li>gifs can only be converted if the user has installed JRE >= 1.6</li> |
---|
991 | * <li>the trailing semi-colon is optional</li> |
---|
992 | * <li>when a file needs to be transformed, the content type will reflect the |
---|
993 | * new picture format. the file extension will be changed dependant on the |
---|
994 | * parameter <code>keepOriginalFileExtensionForConvertedImages</code> |
---|
995 | * <ul> |
---|
996 | * <li>example1: |
---|
997 | * <ul> |
---|
998 | * <li><code>targetPictureFormat="bmp:png;"</code></li> |
---|
999 | * <li><code>keepOriginalFileExtensionForConvertedImages=false</code> (default)</li> |
---|
1000 | * </ul> |
---|
1001 | * When you upload: <code>C:\myBitmap.bmp</code>, the filename will be changed |
---|
1002 | * to <code>C:\myBitmap.png</code> and transferred to the server, and the |
---|
1003 | * content-type will be changed to "image/png"</li> |
---|
1004 | * <li> |
---|
1005 | * <li>example2: |
---|
1006 | * <ul> |
---|
1007 | * <li><code>targetPictureFormat="bmp:png;"</code></li> |
---|
1008 | * <li><code>keepOriginalFileExtensionForConvertedImages=true</code></li> |
---|
1009 | * </ul> |
---|
1010 | * When you upload: <code>C:\myBitmap.bmp</code>, the filename will NOT be |
---|
1011 | * changed and transferred to the server, but the content-type will be changed |
---|
1012 | * to "image/png"</li> |
---|
1013 | * </ul> |
---|
1014 | * </li> |
---|
1015 | * </ul> |
---|
1016 | * see {@link wjhk.jupload2.filedata.helper.ImageFileConversionInfo}<br /> |
---|
1017 | * see keepOriginalFileExtensionForConvertedImages</td> |
---|
1018 | * </tr> |
---|
1019 | * <tr> |
---|
1020 | * <td><b>uploadPolicy</b></td> |
---|
1021 | * <td>DefaultUploadPolicy <br> |
---|
1022 | * <br> |
---|
1023 | * see {@link wjhk.jupload2.policies.UploadPolicyFactory}</td> |
---|
1024 | * <td>This parameter contains the class name for the UploadPolicy that should |
---|
1025 | * be used. If it is not set, or if its value is unknown from |
---|
1026 | * {@link wjhk.jupload2.policies.UploadPolicyFactory#getUploadPolicy(JUploadContext)} |
---|
1027 | * , the {@link wjhk.jupload2.policies.DefaultUploadPolicy} is used.</td> |
---|
1028 | * </tr> |
---|
1029 | * <tr> |
---|
1030 | * <td>urlToSendErrorTo</td> |
---|
1031 | * <td><i>null</i> <br> |
---|
1032 | * <br> |
---|
1033 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}</td> |
---|
1034 | * <td>If this url is given, and an upload error occurs, the applet posts all |
---|
1035 | * debug output to this address. It's up to this URL to handle this message. It |
---|
1036 | * is possible to just store the file, or to log the error in a database, or to |
---|
1037 | * send a mail (like the mail.php script given with the coppermine pack). <br> |
---|
1038 | * <u>Notes:</u> <DIR> |
---|
1039 | * <LI>Only http and https URL schemes are supported.</LI> |
---|
1040 | * <LI>The error information is sent in a POST request sent to the given URL. |
---|
1041 | * These post parameters are used: description (a quick description of the |
---|
1042 | * error), javaError (the java output for the error, or null if no java error |
---|
1043 | * were caught) and debugOutput (the full debug generated by the applet).</LI> |
---|
1044 | * </DIR></td> |
---|
1045 | * </tr> |
---|
1046 | * </table> |
---|
1047 | * <h3><a name="example">HTML call example</a></h3> |
---|
1048 | * <p> |
---|
1049 | * Below, an example of how to put the applet into a PHP page is shown: |
---|
1050 | * </p> |
---|
1051 | * <code><pre> |
---|
1052 | * <applet name="JUpload" code="wjhk.jupload2.JUploadApplet" |
---|
1053 | * archive="plugins/jupload/wjhk.jupload.jar" |
---|
1054 | * <!-- Applet display size, on the navigator page --> |
---|
1055 | * width="500" height="700" |
---|
1056 | * <!-- The applet uses some javascript functions, so we must allow that : --> |
---|
1057 | * mayscript="true"> |
---|
1058 | * <!-- No parameter is mandatory. We don't precise the UploadPolicy, so |
---|
1059 | * DefaultUploadPolicy is used. The applet behaves like the original |
---|
1060 | * JUpload. (jupload v1) --> |
---|
1061 | * <param name="postURL" value="http://some.host.com/youruploadpage.php"> |
---|
1062 | * Java 1.5 or higher plugin required. |
---|
1063 | * </applet> |
---|
1064 | * </pre></code> |
---|
1065 | * <BR> |
---|
1066 | * <!-- ANT_COPYDOC_END --> <!-- ATTENTION: The previous comment is used by Ant |
---|
1067 | * build. DO NOT CHANGE!! --> |
---|
1068 | * |
---|
1069 | * @author etienne_sf |
---|
1070 | * @version $Revision: 1388 $ |
---|
1071 | * @see wjhk.jupload2.policies.DefaultUploadPolicy |
---|
1072 | */ |
---|
1073 | |
---|
1074 | public interface UploadPolicy { |
---|
1075 | |
---|
1076 | /* |
---|
1077 | * Available parameters for the applet. New parameters (for instance for new |
---|
1078 | * policies) should all be added here, in alphabetic order. This ensures |
---|
1079 | * that all tags are unique |
---|
1080 | */ |
---|
1081 | |
---|
1082 | /*************************************************************************** |
---|
1083 | * ************************************************************************ |
---|
1084 | * ************************* LIST OF PROPERTIES ************************** |
---|
1085 | * ************************************************************************ |
---|
1086 | **************************************************************************/ |
---|
1087 | /** |
---|
1088 | * Parameter/Property name for URL to be loaded after an successful upload. |
---|
1089 | */ |
---|
1090 | public final static String PROP_AFTER_UPLOAD_URL = "afterUploadURL"; |
---|
1091 | |
---|
1092 | /** |
---|
1093 | * Parameter/Property name for allowing persistent HTTP connections. |
---|
1094 | */ |
---|
1095 | public final static String PROP_ALLOW_HTTP_PERSISTENT = "allowHttpPersistent"; |
---|
1096 | |
---|
1097 | /** |
---|
1098 | * Parameter/Property name for specifying the allowed file extensions |
---|
1099 | */ |
---|
1100 | public final static String PROP_ALLOWED_FILE_EXTENSIONS = "allowedFileExtensions"; |
---|
1101 | |
---|
1102 | /** |
---|
1103 | * Parameter/Property name for specifying the album id |
---|
1104 | */ |
---|
1105 | public final static String PROP_ALBUM_ID = "albumId"; |
---|
1106 | |
---|
1107 | /** |
---|
1108 | * Indicates the directory, from which the applet should open the browsing |
---|
1109 | * window (file chooser) first. |
---|
1110 | */ |
---|
1111 | public final static String PROP_BROWSING_DIRECTORY = "browsingDirectory"; |
---|
1112 | |
---|
1113 | /** |
---|
1114 | * Parameter/Property name for specifying if images should be cached in |
---|
1115 | * memory. Be careful: if set to true, you'll probably have memory problems |
---|
1116 | * while in a navigator. |
---|
1117 | */ |
---|
1118 | public final static String PROP_STORE_BUFFERED_IMAGE = "storeBufferedImage"; |
---|
1119 | |
---|
1120 | /** |
---|
1121 | * Parameter/Property name for specifying the debug level |
---|
1122 | */ |
---|
1123 | public final static String PROP_DEBUG_LEVEL = "debugLevel"; |
---|
1124 | |
---|
1125 | /** |
---|
1126 | * This parameter allows to control whether the file icons in the file |
---|
1127 | * chooser are calculated from the file content. This is currently only |
---|
1128 | * available for pictures.<BR> |
---|
1129 | * If activated, the file chooser will open each pictures, and calculate the |
---|
1130 | * icon by resizing the picture. This is done in by using thread of minimam |
---|
1131 | * priority, to minimize performances impact on the navigator. Available |
---|
1132 | * values are: <DIR> <LI>-1: disabled. The default system are used. <LI>0 |
---|
1133 | * (default): available only in picture mode. That is: the current upload |
---|
1134 | * policy is an instance of or a class inheriting from |
---|
1135 | * {@link PictureUploadPolicy} <LI>1: available for all upload policies. |
---|
1136 | * </DIR> |
---|
1137 | */ |
---|
1138 | public final static String PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT = "fileChooserIconFromFileContent"; |
---|
1139 | |
---|
1140 | /** |
---|
1141 | * This parameter allows to control the size of icons, in pixels, in the |
---|
1142 | * file chooser. Used only when fileChooserIconFromFileContent is activated. |
---|
1143 | */ |
---|
1144 | public final static String PROP_FILE_CHOOSER_ICON_SIZE = "fileChooserIconSize"; |
---|
1145 | |
---|
1146 | /** |
---|
1147 | * Allows control on the preview on the file chooser. Only for |
---|
1148 | * {@link PictureUploadPolicy} and its inheritants. |
---|
1149 | */ |
---|
1150 | public final static String PROP_FILE_CHOOSER_IMAGE_PREVIEW = "fileChooserImagePreview"; |
---|
1151 | |
---|
1152 | /** |
---|
1153 | * Contains the name of the file filter, as it will be displayed in the drop |
---|
1154 | * down list of filters, in the file chooser. If this name is given to the |
---|
1155 | * applet, it will be returned by the {@link FileFilter#getDescription()} |
---|
1156 | * method. |
---|
1157 | */ |
---|
1158 | public final static String PROP_FILE_FILTER_NAME = "fileFilterName"; |
---|
1159 | |
---|
1160 | /** |
---|
1161 | * Parameter/Property name for specifying the encoding of file names. |
---|
1162 | */ |
---|
1163 | public final static String PROP_FILENAME_ENCODING = "filenameEncoding"; |
---|
1164 | |
---|
1165 | /** |
---|
1166 | * Parameter/Property name for specifying additional form data. |
---|
1167 | */ |
---|
1168 | public final static String PROP_FORMDATA = "formdata"; |
---|
1169 | |
---|
1170 | /** |
---|
1171 | * Parameter/Property name to specify, when in FTP mode, if subfolders must |
---|
1172 | * be created, or if all files must be uploaded on the root of postURL. |
---|
1173 | */ |
---|
1174 | public final static String PROP_FTP_CREATE_DIRECTORY_STRUCTURE = "ftpCreateDirectoryStructure"; |
---|
1175 | |
---|
1176 | /** FTP: binary or ascii mode */ |
---|
1177 | public final static String PROP_FTP_TRANSFERT_BINARY = "ftpTransfertBinary"; |
---|
1178 | |
---|
1179 | /** FTP: passive or active mode */ |
---|
1180 | public final static String PROP_FTP_TRANSFERT_PASSIVE = "ftpTransfertPassive"; |
---|
1181 | |
---|
1182 | /** |
---|
1183 | * Parameter/Property name for specifying high quality previews. |
---|
1184 | */ |
---|
1185 | public final static String PROP_HIGH_QUALITY_PREVIEW = "highQualityPreview"; |
---|
1186 | |
---|
1187 | /** |
---|
1188 | * Parameter/Property name for specifying high quality previews. |
---|
1189 | */ |
---|
1190 | public final static String PROP_HTTP_UPLOAD_PARAMETER_NAME = "httpUploadParameterName"; |
---|
1191 | |
---|
1192 | /** |
---|
1193 | * Parameter/Property name for specifying high quality previews. |
---|
1194 | */ |
---|
1195 | public final static String PROP_HTTP_UPLOAD_PARAMETER_TYPE = "httpUploadParameterType"; |
---|
1196 | |
---|
1197 | /** |
---|
1198 | * Parameter/Property name for specifying the UI language |
---|
1199 | */ |
---|
1200 | public final static String PROP_LANG = "lang"; |
---|
1201 | |
---|
1202 | /** |
---|
1203 | * Parameter/Property name for specifying a list of specific headers, that |
---|
1204 | * will be added to all HTTP request to the server. The parameter can be |
---|
1205 | * used for Basic Authentication, by adding this header: Authorization: |
---|
1206 | * Basic [Bae64 encoding of the string "user:password"] |
---|
1207 | */ |
---|
1208 | public final static String PROP_SPECIFIC_HEADERS = "specificHeaders"; |
---|
1209 | |
---|
1210 | /** |
---|
1211 | * Parameter/Property name for specifying a PLAF class to load. |
---|
1212 | */ |
---|
1213 | public final static String PROP_LOOK_AND_FEEL = "lookAndFeel"; |
---|
1214 | |
---|
1215 | /** |
---|
1216 | * Parameter/Property name for specifying the maximum size of a chunk of |
---|
1217 | * uploaded data. |
---|
1218 | */ |
---|
1219 | public final static String PROP_MAX_CHUNK_SIZE = "maxChunkSize"; |
---|
1220 | |
---|
1221 | /** |
---|
1222 | * Parameter/Property name for specifying the maximum size of a single file. |
---|
1223 | */ |
---|
1224 | public final static String PROP_MAX_FILE_SIZE = "maxFileSize"; |
---|
1225 | |
---|
1226 | /** |
---|
1227 | * Parameter/Property name for specifying the maximum height of a picture. |
---|
1228 | */ |
---|
1229 | public final static String PROP_MAX_HEIGHT = "maxPicHeight"; |
---|
1230 | |
---|
1231 | /** |
---|
1232 | * Parameter/Property name for specifying the maximum width of a picture. |
---|
1233 | */ |
---|
1234 | public final static String PROP_MAX_WIDTH = "maxPicWidth"; |
---|
1235 | |
---|
1236 | /** |
---|
1237 | * Parameter/Property name for specifying the maximum number of file to be |
---|
1238 | * uploaded in a single request. |
---|
1239 | */ |
---|
1240 | public final static String PROP_NB_FILES_PER_REQUEST = "nbFilesPerRequest"; |
---|
1241 | |
---|
1242 | /** |
---|
1243 | * Parameter/Property name for specifying compression of the written picture |
---|
1244 | * file, if any. |
---|
1245 | */ |
---|
1246 | public final static String PROP_PICTURE_COMPRESSION_QUALITY = "pictureCompressionQuality"; |
---|
1247 | |
---|
1248 | /** |
---|
1249 | * Parameter/Property name for specifying whether picture metadata (EXIF |
---|
1250 | * coming from the camera for instance. |
---|
1251 | */ |
---|
1252 | public final static String PROP_PICTURE_TRANSMIT_METADATA = "pictureTransmitMetadata"; |
---|
1253 | |
---|
1254 | /** |
---|
1255 | * Parameter/Property name for specifying URL of the upload post request. |
---|
1256 | */ |
---|
1257 | public final static String PROP_POST_URL = "postURL"; |
---|
1258 | |
---|
1259 | /** |
---|
1260 | * Parameter/Property name for specifying URL of the upload post request. |
---|
1261 | */ |
---|
1262 | public final static String PROP_AFTER_UPLOAD_TARGET = "afterUploadTarget"; |
---|
1263 | |
---|
1264 | /** |
---|
1265 | * Read cookies from javascript command: document.cookie (or not) |
---|
1266 | */ |
---|
1267 | public final static String PROP_READ_COOKIE_FROM_NAVIGATOR = "readCookieFromNavigator"; |
---|
1268 | |
---|
1269 | /** |
---|
1270 | * Read userAgent from javascript command: document.userAgent (or not) |
---|
1271 | */ |
---|
1272 | public final static String PROP_READ_USER_AGENT_FROM_NAVIGATOR = "readUserAgentFromNavigator"; |
---|
1273 | |
---|
1274 | /** |
---|
1275 | * Parameter/Property name for specifying the real (server-side-desired) |
---|
1276 | * picture height. |
---|
1277 | */ |
---|
1278 | public final static String PROP_REAL_MAX_HEIGHT = "realMaxPicHeight"; |
---|
1279 | |
---|
1280 | /** |
---|
1281 | * Parameter/Property name for specifying the real (server-side-desired) |
---|
1282 | * picture width. |
---|
1283 | */ |
---|
1284 | public final static String PROP_REAL_MAX_WIDTH = "realMaxPicWidth"; |
---|
1285 | |
---|
1286 | /** |
---|
1287 | * Maximum number of retries, that the applet will do, for upload resumable |
---|
1288 | * error. A 'upload resumable error', is typically a network error. The |
---|
1289 | * default value is 0, to maintain the same behaviour as before. |
---|
1290 | */ |
---|
1291 | public final static String PROP_RETRY_MAX_NUMBER_OF = "retryMaxNumberOf"; |
---|
1292 | |
---|
1293 | /** |
---|
1294 | * The number of seconds, to wait, before trying a new upload. This is used |
---|
1295 | * if <I>retryMaxNumberOf</I> is 1 or more, and if 'resumable upload error' |
---|
1296 | * occurs. |
---|
1297 | */ |
---|
1298 | public final static String PROP_RETRY_NB_SECONDS_BETWEEN = "retryNbSecondsBetween"; |
---|
1299 | |
---|
1300 | /** |
---|
1301 | * Parameter/Property name for specifying the server protocol version. |
---|
1302 | */ |
---|
1303 | public final static String PROP_SERVER_PROTOCOL = "serverProtocol"; |
---|
1304 | |
---|
1305 | /** |
---|
1306 | * Parameter/Property name to spceify whether the md5sum for uploaded file |
---|
1307 | * should be sent. |
---|
1308 | */ |
---|
1309 | public final static String PROP_SEND_MD5_SUM = "sendMD5Sum"; |
---|
1310 | |
---|
1311 | /** |
---|
1312 | * Parameter/Property name for specifying if the log window should be |
---|
1313 | * visible. |
---|
1314 | */ |
---|
1315 | public final static String PROP_SHOW_LOGWINDOW = "showLogWindow"; |
---|
1316 | |
---|
1317 | /** |
---|
1318 | * Parameter/Property name for specifying if the status bar should be |
---|
1319 | * visible. |
---|
1320 | */ |
---|
1321 | public final static String PROP_SHOW_STATUSBAR = "showStatusbar"; |
---|
1322 | |
---|
1323 | /** |
---|
1324 | * Parameter/Property name for specifying how certificates are handled when |
---|
1325 | * uploading via SSL. |
---|
1326 | */ |
---|
1327 | public final static String PROP_SSL_VERIFY_CERT = "sslVerifyCert"; |
---|
1328 | |
---|
1329 | /** |
---|
1330 | * Parameter/Property name for specifying if the pattern that indicates an |
---|
1331 | * error in the server's response-body. |
---|
1332 | */ |
---|
1333 | public final static String PROP_STRING_UPLOAD_ERROR = "stringUploadError"; |
---|
1334 | |
---|
1335 | /** |
---|
1336 | * Parameter/Property name for specifying if the pattern that indicates |
---|
1337 | * success in the server's response-body. |
---|
1338 | */ |
---|
1339 | public final static String PROP_STRING_UPLOAD_SUCCESS = "stringUploadSuccess"; |
---|
1340 | |
---|
1341 | /** |
---|
1342 | * Parameter/Property name for specifying if the pattern that indicates a |
---|
1343 | * warning in the server's response-body. |
---|
1344 | */ |
---|
1345 | public final static String PROP_STRING_UPLOAD_WARNING = "stringUploadWarning"; |
---|
1346 | |
---|
1347 | /** |
---|
1348 | * Parameter/Property name for specifying the target picture format |
---|
1349 | * conversions |
---|
1350 | */ |
---|
1351 | public final static String PROP_TARGET_PICTURE_FORMAT = "targetPictureFormat"; |
---|
1352 | |
---|
1353 | /** |
---|
1354 | * Parameter/Property name for specifying if the original file extension |
---|
1355 | * should be changed if an image is converted to another format |
---|
1356 | */ |
---|
1357 | public final static String PROP_KEEP_ORIG_EXTENSION = "keepOriginalFileExtensionForConvertedImages"; |
---|
1358 | |
---|
1359 | /** |
---|
1360 | * Parameter/Property name for specifying the upload policy class. |
---|
1361 | */ |
---|
1362 | public final static String PROP_UPLOAD_POLICY = "uploadPolicy"; |
---|
1363 | |
---|
1364 | /** |
---|
1365 | * Parameter/Property name for specifying the URL for delivering error |
---|
1366 | * reports. |
---|
1367 | */ |
---|
1368 | public final static String PROP_URL_TO_SEND_ERROR_TO = "urlToSendErrorTo"; |
---|
1369 | |
---|
1370 | /*************************************************************************** |
---|
1371 | * ************************************************************************ |
---|
1372 | * ************************* LIST OF ALLOWED VALUES ********************* |
---|
1373 | * ************************************************************************ |
---|
1374 | **************************************************************************/ |
---|
1375 | |
---|
1376 | /** |
---|
1377 | * Indicates that, in the HTTP upload request, the parameter that containts |
---|
1378 | * the uploaded files is an Iteration. For instance: from File0 to FileN |
---|
1379 | * (for N+1 files). |
---|
1380 | */ |
---|
1381 | public final String HTTPUPLOADPARAMETERTYPE_ARRAY = "array"; |
---|
1382 | |
---|
1383 | /** |
---|
1384 | * Indicates that, in the HTTP upload request, the parameter that containts |
---|
1385 | * the uploaded files is an Iteration. For instance: from File0 to FileN |
---|
1386 | * (for N+1 files). |
---|
1387 | */ |
---|
1388 | public final String HTTPUPLOADPARAMETERTYPE_ITERATION = "iteration"; |
---|
1389 | |
---|
1390 | /** |
---|
1391 | * Indicates that, in the HTTP upload request, there will be only one file. |
---|
1392 | * This value is only valid when nbFilesPerRequest is 1. The parameters in |
---|
1393 | * the HTTP upload request are let untransformed. For instance, if |
---|
1394 | * httpUploadParameterName is the default value (File), the file content |
---|
1395 | * will be loaded under the HTTP parameter 'File'. |
---|
1396 | */ |
---|
1397 | public final String HTTPUPLOADPARAMETERTYPE_ONE_FILE = "oneFile"; |
---|
1398 | |
---|
1399 | /** Indicates that the log window is always visible. */ |
---|
1400 | public final String SHOWLOGWINDOW_TRUE = "true"; |
---|
1401 | |
---|
1402 | /** Indicates that the log window is always hidden. */ |
---|
1403 | public final String SHOWLOGWINDOW_FALSE = "false"; |
---|
1404 | |
---|
1405 | /** |
---|
1406 | * Indicates that the log window is hidden, and will become visible only |
---|
1407 | * when an error occurs. |
---|
1408 | */ |
---|
1409 | public final String SHOWLOGWINDOW_ONERROR = "onError"; |
---|
1410 | |
---|
1411 | /*************************************************************************** |
---|
1412 | * ************************************************************************ |
---|
1413 | * ************************* LIST OF DEFAULT VALUES ********************** |
---|
1414 | * ************************************************************************ |
---|
1415 | **************************************************************************/ |
---|
1416 | |
---|
1417 | /** |
---|
1418 | * Default value for parameter "afterUploadTarget". |
---|
1419 | */ |
---|
1420 | public final static String DEFAULT_AFTER_UPLOAD_TARGET = null; |
---|
1421 | |
---|
1422 | /** |
---|
1423 | * Default value for parameter "afterUploadURL" |
---|
1424 | */ |
---|
1425 | public final static String DEFAULT_AFTER_UPLOAD_URL = null; |
---|
1426 | |
---|
1427 | /** |
---|
1428 | * Default value for parameter "allowHttpPersisten". |
---|
1429 | */ |
---|
1430 | public final static boolean DEFAULT_ALLOW_HTTP_PERSISTENT = false; |
---|
1431 | |
---|
1432 | /** |
---|
1433 | * Default value for parameter "allowedFileExtensions". |
---|
1434 | */ |
---|
1435 | public final static String DEFAULT_ALLOWED_FILE_EXTENSIONS = null; |
---|
1436 | |
---|
1437 | /** |
---|
1438 | * Default value for parameter "albumId". |
---|
1439 | */ |
---|
1440 | public final static int DEFAULT_ALBUM_ID = 0; |
---|
1441 | |
---|
1442 | /** |
---|
1443 | * Default value for parameter "storeBufferedImage". Be careful: if set to |
---|
1444 | * true, you'll probably have memory problems while in a navigator. |
---|
1445 | */ |
---|
1446 | public final static boolean DEFAULT_STORE_BUFFERED_IMAGE = false; |
---|
1447 | |
---|
1448 | /** |
---|
1449 | * Default value for the browsing window first: no specific directory. |
---|
1450 | */ |
---|
1451 | public final static String DEFAULT_BROWSING_DIRECTORY = null; |
---|
1452 | |
---|
1453 | /** |
---|
1454 | * Default value for date format when changing date/time variable to String. |
---|
1455 | */ |
---|
1456 | public final static String DEFAULT_DATE_FORMAT = "dd/MM/yyyy HH:mm:ss"; |
---|
1457 | |
---|
1458 | /** |
---|
1459 | * Default value for parameter "debugLevel". |
---|
1460 | */ |
---|
1461 | public final static int DEFAULT_DEBUG_LEVEL = 0; |
---|
1462 | |
---|
1463 | /** |
---|
1464 | * Default value for applet parameter "fileChooserIconFromFileContent". |
---|
1465 | * |
---|
1466 | * @see #PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT |
---|
1467 | */ |
---|
1468 | public final static int DEFAULT_FILE_CHOOSER_ICON_FROM_FILE_CONTENT = 0; |
---|
1469 | |
---|
1470 | /** |
---|
1471 | * Default value for applet parameter "fileChooserIconSize". |
---|
1472 | * |
---|
1473 | * @see #PROP_FILE_CHOOSER_ICON_SIZE |
---|
1474 | */ |
---|
1475 | public final static int DEFAULT_FILE_CHOOSER_ICON_SIZE = 20; |
---|
1476 | |
---|
1477 | /** |
---|
1478 | * Default value for applet parameter "fileChooserImagePreview". |
---|
1479 | * |
---|
1480 | * @see #PROP_FILE_CHOOSER_IMAGE_PREVIEW |
---|
1481 | */ |
---|
1482 | public final static boolean DEFAULT_FILE_CHOOSER_IMAGE_PREVIEW = true; |
---|
1483 | |
---|
1484 | /** |
---|
1485 | * Default value for applet parameter "fileFilterName". This default value |
---|
1486 | * let the {@link DefaultUploadPolicy} return a calculated name, which |
---|
1487 | * contains the list of allowed file extensions. |
---|
1488 | * |
---|
1489 | * @see #PROP_FILE_FILTER_NAME |
---|
1490 | * @see #PROP_ALLOWED_FILE_EXTENSIONS |
---|
1491 | */ |
---|
1492 | public final static String DEFAULT_FILE_FILTER_NAME = null; |
---|
1493 | |
---|
1494 | /** |
---|
1495 | * Default value for applet parameter "ftpCreateDirectoryStructure". |
---|
1496 | * |
---|
1497 | * @see #PROP_FTP_CREATE_DIRECTORY_STRUCTURE |
---|
1498 | */ |
---|
1499 | public final static boolean DEFAULT_FTP_CREATE_DIRECTORY_STRUCTURE = false; |
---|
1500 | |
---|
1501 | /** FTP: binary or ascii mode */ |
---|
1502 | public final static boolean DEFAULT_FTP_TRANSFERT_BINARY = true; |
---|
1503 | |
---|
1504 | /** FTP: passive or active mode */ |
---|
1505 | public final static boolean DEFAULT_FTP_TRANSFERT_PASSIVE = true; |
---|
1506 | |
---|
1507 | /** Default value for parameter "lang". */ |
---|
1508 | public final static String DEFAULT_LANG = null; |
---|
1509 | |
---|
1510 | /** |
---|
1511 | * Default value for parameter "filenameEncoding". Note: the |
---|
1512 | * CoppermineUploadPolicy forces it to "UTF8". |
---|
1513 | */ |
---|
1514 | public final static String DEFAULT_FILENAME_ENCODING = null; |
---|
1515 | |
---|
1516 | /** Default value for parameter "highQualityPreview". */ |
---|
1517 | public final static boolean DEFAULT_HIGH_QUALITY_PREVIEW = false; |
---|
1518 | |
---|
1519 | /** Default value for parameter "httpUploadParameterName". */ |
---|
1520 | public final static String DEFAULT_HTTP_UPLOAD_PARAMETER_NAME = "File"; |
---|
1521 | |
---|
1522 | /** Default value for parameter "httpUploadParameterName". */ |
---|
1523 | public final static String DEFAULT_HTTP_UPLOAD_PARAMETER_TYPE = HTTPUPLOADPARAMETERTYPE_ITERATION; |
---|
1524 | |
---|
1525 | /** Default value for parameter "lookAndFeel". */ |
---|
1526 | public final static String DEFAULT_LOOK_AND_FEEL = ""; |
---|
1527 | |
---|
1528 | /** Default value for parameter "maxChunkSize". */ |
---|
1529 | public final static long DEFAULT_MAX_CHUNK_SIZE = Long.MAX_VALUE; |
---|
1530 | |
---|
1531 | /** |
---|
1532 | * Default value for parameter "maxFileSize". Take care of this parameter if |
---|
1533 | * chunk upload is activated! See comment above. |
---|
1534 | */ |
---|
1535 | public final static long DEFAULT_MAX_FILE_SIZE = Long.MAX_VALUE; |
---|
1536 | |
---|
1537 | /** Default value for parameter "maxPicWidth". */ |
---|
1538 | public final static int DEFAULT_MAX_WIDTH = Integer.MAX_VALUE; |
---|
1539 | |
---|
1540 | /** Default value for parameter "maxPicHeight". */ |
---|
1541 | public final static int DEFAULT_MAX_HEIGHT = Integer.MAX_VALUE; |
---|
1542 | |
---|
1543 | /** |
---|
1544 | * Default value for parameter "maxPicHeight". Note: the |
---|
1545 | * CoppermineUploadPolicy forces it to 1. |
---|
1546 | */ |
---|
1547 | public final static int DEFAULT_NB_FILES_PER_REQUEST = 1; |
---|
1548 | |
---|
1549 | /** |
---|
1550 | * Default value for parameter "pictureCompressionQuality". |
---|
1551 | */ |
---|
1552 | public final static float DEFAULT_PICTURE_COMPRESSION_QUALITY = (float) 0.8; |
---|
1553 | |
---|
1554 | /** |
---|
1555 | * Default value for parameter "pictureCompressionQuality". |
---|
1556 | */ |
---|
1557 | public final static boolean DEFAULT_PICTURE_TRANSMIT_METADATA = false; |
---|
1558 | |
---|
1559 | /** |
---|
1560 | * Default value for parameter "postURL". |
---|
1561 | */ |
---|
1562 | public final static String DEFAULT_POST_URL = null; |
---|
1563 | |
---|
1564 | /** |
---|
1565 | * Default value for parameter "readCookieFromNavigator". |
---|
1566 | */ |
---|
1567 | public final static boolean DEFAULT_READ_COOKIE_FROM_NAVIGATOR = true; |
---|
1568 | |
---|
1569 | /** |
---|
1570 | * Default value for parameter "readUserAgentFromNavigator". |
---|
1571 | */ |
---|
1572 | public final static boolean DEFAULT_READ_USER_AGENT_FROM_NAVIGATOR = true; |
---|
1573 | |
---|
1574 | /** |
---|
1575 | * Default value for parameter "realMaxPicWidth". |
---|
1576 | */ |
---|
1577 | public final static int DEFAULT_REAL_MAX_WIDTH = Integer.MAX_VALUE; |
---|
1578 | |
---|
1579 | /** |
---|
1580 | * Default value for parameter "realMaxPicHeight". |
---|
1581 | */ |
---|
1582 | public final static int DEFAULT_REAL_MAX_HEIGHT = Integer.MAX_VALUE; |
---|
1583 | |
---|
1584 | /** |
---|
1585 | * Default value for parameter "retryMaxNumberOf". |
---|
1586 | */ |
---|
1587 | public final static int DEFAULT_RETRY_MAX_NUMBER_OF = 1; |
---|
1588 | |
---|
1589 | /** |
---|
1590 | * Default value for parameter "retryNbSecondsBetween". |
---|
1591 | */ |
---|
1592 | public final static int DEFAULT_RETRY_NB_SECONDS_BETWEEN = 30; |
---|
1593 | |
---|
1594 | /** |
---|
1595 | * Default value for parameter "serverProtocol". |
---|
1596 | */ |
---|
1597 | public final static String DEFAULT_SERVER_PROTOCOL = "HTTP/1.1"; |
---|
1598 | |
---|
1599 | /** |
---|
1600 | * Default value for the sendMD5Sum applet parameter |
---|
1601 | */ |
---|
1602 | public final static boolean DEFAULT_SEND_MD5_SUM = false; |
---|
1603 | |
---|
1604 | /** |
---|
1605 | * Default value for parameter "showLogWindow". |
---|
1606 | */ |
---|
1607 | public final static String DEFAULT_SHOW_LOGWINDOW = "true"; |
---|
1608 | |
---|
1609 | /** |
---|
1610 | * Default value for parameter "showStatusBar". |
---|
1611 | */ |
---|
1612 | public final static boolean DEFAULT_SHOW_STATUSBAR = true; |
---|
1613 | |
---|
1614 | /** |
---|
1615 | * Default value for parameter "sslVerifyCert" |
---|
1616 | */ |
---|
1617 | public final static String DEFAULT_SPECIFIC_HEADERS = null; |
---|
1618 | |
---|
1619 | /** |
---|
1620 | * Default value for parameter "sslVerifyCert" |
---|
1621 | */ |
---|
1622 | public final static String DEFAULT_SSL_VERIFY_CERT = "none"; |
---|
1623 | |
---|
1624 | /** |
---|
1625 | * Default value for parameter "stringUploadError". |
---|
1626 | * |
---|
1627 | * @since 2.9.2rc4 |
---|
1628 | */ |
---|
1629 | public final static String DEFAULT_STRING_UPLOAD_ERROR = "^ERROR: (.*)$"; |
---|
1630 | |
---|
1631 | /** |
---|
1632 | * Default value for parameter "stringUploadSuccess". Note: was ".* 200 OK$" |
---|
1633 | * before 2.9.0 |
---|
1634 | */ |
---|
1635 | public final static String DEFAULT_STRING_UPLOAD_SUCCESS = "^SUCCESS$"; |
---|
1636 | |
---|
1637 | /** |
---|
1638 | * Default value for parameter "stringUploadWarning". |
---|
1639 | */ |
---|
1640 | public final static String DEFAULT_STRING_UPLOAD_WARNING = "^WARNING: (.*)$"; |
---|
1641 | |
---|
1642 | /** |
---|
1643 | * Default value for parameter "targetPictureFormat". |
---|
1644 | */ |
---|
1645 | public final static String DEFAULT_TARGET_PICTURE_FORMAT = null; |
---|
1646 | |
---|
1647 | /** |
---|
1648 | * default value for parameter "keepOriginalFileExtensionForConvertedImages" |
---|
1649 | */ |
---|
1650 | public final static boolean DEFAULT_KEEP_ORIG_EXTENSION = false; |
---|
1651 | |
---|
1652 | /** |
---|
1653 | * Default value for parameter "uploadPolicy". |
---|
1654 | */ |
---|
1655 | public final static String DEFAULT_UPLOAD_POLICY = "DefaultUploadPolicy"; |
---|
1656 | |
---|
1657 | /** |
---|
1658 | * Default value for parameter "urlToSendErrorTo". |
---|
1659 | */ |
---|
1660 | public final static String DEFAULT_URL_TO_SEND_ERROR_TO = null; |
---|
1661 | |
---|
1662 | /** |
---|
1663 | * Default value for parameter "formdata" |
---|
1664 | * |
---|
1665 | * @since 2.9.2rc4 |
---|
1666 | */ |
---|
1667 | public final static String DEFAULT_FORMDATA = null; |
---|
1668 | |
---|
1669 | /***************************************************************************/ |
---|
1670 | /******************** MISC CONSTANTS ***************************************/ |
---|
1671 | /***************************************************************************/ |
---|
1672 | |
---|
1673 | /** |
---|
1674 | * Indicating that the applet is currently waiting for the user, to select |
---|
1675 | * files or start an uploading. |
---|
1676 | */ |
---|
1677 | public final static int EXEC_STATUS_READY = 1; |
---|
1678 | /** Indicating that the applet is currently uploading files */ |
---|
1679 | public final static int EXEC_STATUS_UPLOADING = 2; |
---|
1680 | |
---|
1681 | /*************************************************************************** |
---|
1682 | * ************************************************************************* |
---|
1683 | * ********************* LIST OF METHODS ********************************** |
---|
1684 | * ************************************************************************* |
---|
1685 | **************************************************************************/ |
---|
1686 | |
---|
1687 | /** |
---|
1688 | * This method allows the upolad policy to override the content of the |
---|
1689 | * applet part that is above the file list, called here the 'top panel'. |
---|
1690 | * That is: the part that contains the Browse, Remove and RemoveAll buttons. |
---|
1691 | * The default implementation is defined in |
---|
1692 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy#createTopPanel(JButton, JButton, JButton, JUploadPanel)} |
---|
1693 | * . <BR> |
---|
1694 | * You can see an example in the |
---|
1695 | * {@link PictureUploadPolicy#createTopPanel(JButton, JButton, JButton, JUploadPanel)} |
---|
1696 | * upload policy implementation. <BR> |
---|
1697 | * <B>Note:</B> This method is called by the |
---|
1698 | * {@link DefaultUploadPolicy#addComponentsToJUploadPanel(JUploadPanel)} |
---|
1699 | * method. If you create an upload policy that overrides the |
---|
1700 | * addComponentsToJUploadPanel method, it's up to you to call it. |
---|
1701 | * |
---|
1702 | * @param browse |
---|
1703 | * The default browse button. |
---|
1704 | * @param remove |
---|
1705 | * The default removeSelected button. |
---|
1706 | * @param removeAll |
---|
1707 | * The default removeAll button. |
---|
1708 | * @param mainPanel |
---|
1709 | * The panel that contains all objects. |
---|
1710 | * @return the topPanel, that will be displayed on the top of the Applet. |
---|
1711 | */ |
---|
1712 | public JPanel createTopPanel(JButton browse, JButton remove, |
---|
1713 | JButton removeAll, JUploadPanel mainPanel); |
---|
1714 | |
---|
1715 | /** |
---|
1716 | * This method is called to create the progress panel. The default |
---|
1717 | * implementation is defined in |
---|
1718 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy#createProgressPanel(JProgressBar, JProgressBar, JButton, JButton, JUploadPanel)} |
---|
1719 | * . |
---|
1720 | * |
---|
1721 | * @param preparationProgressBar |
---|
1722 | * The default preparation progress bar. |
---|
1723 | * @param uploadProgressBar |
---|
1724 | * The default upload progress bar. |
---|
1725 | * @param uploadButton |
---|
1726 | * The default upload button. |
---|
1727 | * @param stopButton |
---|
1728 | * The default stop button. |
---|
1729 | * @param mainPanel |
---|
1730 | * The panel that contains all objects. |
---|
1731 | * @return the topPanel, that will be displayed on the top of the Applet. |
---|
1732 | */ |
---|
1733 | public JPanel createProgressPanel(JProgressBar preparationProgressBar, |
---|
1734 | JProgressBar uploadProgressBar, JButton uploadButton, |
---|
1735 | JButton stopButton, JUploadPanel mainPanel); |
---|
1736 | |
---|
1737 | /** |
---|
1738 | * This method is used to create a new status bar. The default |
---|
1739 | * implementation is defined in |
---|
1740 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy#createStatusBar(JLabel, JUploadPanel)} |
---|
1741 | * . |
---|
1742 | * |
---|
1743 | * @param statusContent |
---|
1744 | * The status bar content |
---|
1745 | * @param mainPanel |
---|
1746 | * The panel that contains all objects. |
---|
1747 | * @return the topPanel, that will be displayed on the top of the Applet. |
---|
1748 | */ |
---|
1749 | public JPanel createStatusBar(JLabel statusContent, JUploadPanel mainPanel); |
---|
1750 | |
---|
1751 | /** |
---|
1752 | * This methods allow the upload policy to override the default disposition |
---|
1753 | * of the components on the applet.<br> |
---|
1754 | * There are some utility methods to style file panel elements (font/color), see |
---|
1755 | * {@link wjhk.jupload2.gui.filepanel.FilePanel}. |
---|
1756 | * @param jUploadPanel |
---|
1757 | * The main applet panel. |
---|
1758 | * @see #createTopPanel(JButton, JButton, JButton, JUploadPanel) |
---|
1759 | */ |
---|
1760 | public void addComponentsToJUploadPanel(JUploadPanel jUploadPanel); |
---|
1761 | |
---|
1762 | /** |
---|
1763 | * This methods creates a new FileData instance (or one of its inherited |
---|
1764 | * classes), and return it to the caller. |
---|
1765 | * |
---|
1766 | * @param file |
---|
1767 | * The file used to create the FileData instance. This method is |
---|
1768 | * called once for each file selected by the user, even if the |
---|
1769 | * user added several files in one 'shot'. |
---|
1770 | * @param root |
---|
1771 | * An optional toplevel directory of a hierarchy (can be null). |
---|
1772 | * @return A FileData instance. The exact class depends on the |
---|
1773 | * currentUploadPolicy. Can be null, if the policy performs checks, |
---|
1774 | * and the given file is not Ok for these controls. See |
---|
1775 | * {@link PictureUploadPolicy#createFileData(File,File)} for an |
---|
1776 | * example. It's up to the upload policy to display a message to |
---|
1777 | * inform the user that this file won't be added to the file list. |
---|
1778 | * @throws JUploadExceptionStopAddingFiles |
---|
1779 | * The exception is not really an error. It allows an easy way |
---|
1780 | * to indicates that the applet should stop adding files when |
---|
1781 | * the user clicked on the 'Cancel' button. |
---|
1782 | */ |
---|
1783 | public FileData createFileData(File file, File root) |
---|
1784 | throws JUploadExceptionStopAddingFiles; |
---|
1785 | |
---|
1786 | /** |
---|
1787 | * This method displays the applet parameter list, according to the current |
---|
1788 | * debugLevel. It is called by the {@link #setDebugLevel(int)} method. It |
---|
1789 | * should be override by any subclasses, that should display its own |
---|
1790 | * parameters, then call <i>super.displayParameterStatus()</i>. |
---|
1791 | */ |
---|
1792 | public void displayParameterStatus(); |
---|
1793 | |
---|
1794 | /** |
---|
1795 | * Reaction to the applet start. This method was added from the patch |
---|
1796 | * 3035735 given by Tsukasa Hamano (SF login: cuspy). Its aim is to move all |
---|
1797 | * call to JSObject from the applet.init() method to the applet.start() |
---|
1798 | * method. This prevents a crash, under Safari. |
---|
1799 | */ |
---|
1800 | public void start(); |
---|
1801 | |
---|
1802 | /** |
---|
1803 | * This method is called by the {@link JUploadPanel#updateButtonState()} |
---|
1804 | * method, when the execution status of the applet changes. This allow the |
---|
1805 | * applet to manage specific GUI items, depending on the current execution |
---|
1806 | * status of the applet. |
---|
1807 | * |
---|
1808 | * @param executionStatus |
---|
1809 | * One of the EXEC_STATUS_XXX constant. |
---|
1810 | */ |
---|
1811 | public void updateButtonState(int executionStatus); |
---|
1812 | |
---|
1813 | // ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
1814 | // /////////////////// getters / setters |
---|
1815 | // ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
1816 | |
---|
1817 | /** |
---|
1818 | * This allow runtime modifications of properties. With this method, you can |
---|
1819 | * change any applet parameter after the applet initilization, with |
---|
1820 | * JavaScript for instance. If the applet parameters given in <i>prop</i> is |
---|
1821 | * not managed by this method, a warning is displayed in the log window. |
---|
1822 | * |
---|
1823 | * @param prop |
---|
1824 | * The applet parameter name. |
---|
1825 | * @param value |
---|
1826 | * The new value for this parameter. If the value is not valid |
---|
1827 | * (for instance <i>aaa</i> for a number), a warning is displayed |
---|
1828 | * in the log window, and the existing value is not changed. |
---|
1829 | * @throws JUploadException |
---|
1830 | * @exception JUploadExceptionStopAddingFiles |
---|
1831 | * indicates that the applet should stop strying adding the |
---|
1832 | * current file selection. Useful for instance, when a user |
---|
1833 | * drop a directory, full of unallowed file: it's annoying |
---|
1834 | * for the user to click 'Ok' for each file in the alert box. |
---|
1835 | */ |
---|
1836 | public void setProperty(String prop, String value) throws JUploadException; |
---|
1837 | |
---|
1838 | /** |
---|
1839 | * Retrieves the current value for the afterUploadURL applet parameter. |
---|
1840 | * |
---|
1841 | * @return The current value for he afterUploadURL applet parameter. |
---|
1842 | */ |
---|
1843 | public String getAfterUploadURL(); |
---|
1844 | |
---|
1845 | /** |
---|
1846 | * Retrieves the current value for allowHttpPersistent |
---|
1847 | * |
---|
1848 | * @return Current value for allowHttpPersistent |
---|
1849 | */ |
---|
1850 | public boolean getAllowHttpPersistent(); |
---|
1851 | |
---|
1852 | /** |
---|
1853 | * Retrieves the current value for allowedFileExtensions * |
---|
1854 | * |
---|
1855 | * @return Current value for allowedFileExtensions |
---|
1856 | */ |
---|
1857 | public String getAllowedFileExtensions(); |
---|
1858 | |
---|
1859 | /** |
---|
1860 | * A useful function, that has nothing to do with an upload policy. But it |
---|
1861 | * is useful to have it here, as the uploadPolicy is known everywhere in the |
---|
1862 | * applet. |
---|
1863 | * |
---|
1864 | * @return Reference to the current JUpload context. |
---|
1865 | */ |
---|
1866 | public JUploadContext getContext(); |
---|
1867 | |
---|
1868 | /** |
---|
1869 | * Set the current directory. |
---|
1870 | * |
---|
1871 | * @param currentBrowsingDirectoryParam |
---|
1872 | * The directory that will be the current one, the next time the |
---|
1873 | * file chooser is opened. |
---|
1874 | * @see #getCurrentBrowsingDirectory() |
---|
1875 | * @deprecated |
---|
1876 | */ |
---|
1877 | public void setCurrentBrowsingDirectory(File currentBrowsingDirectoryParam); |
---|
1878 | |
---|
1879 | /** |
---|
1880 | * Set the current directory. |
---|
1881 | * |
---|
1882 | * @param currentBrowsingDirectoryParam |
---|
1883 | * The directory that will be the current one, the next time the |
---|
1884 | * file chooser is opened. This directory may begin with ~/ or ~\ |
---|
1885 | * @see #getCurrentBrowsingDirectory() |
---|
1886 | */ |
---|
1887 | public void setCurrentBrowsingDirectory(String currentBrowsingDirectoryParam); |
---|
1888 | |
---|
1889 | /** |
---|
1890 | * Returns the current browsing directory, that is: the directory that will |
---|
1891 | * be current the next time the file chooser is opened. It is initialized |
---|
1892 | * with the browsingDirectory applet parameter. Then, it contains the last |
---|
1893 | * directory used in the file chooser. |
---|
1894 | * |
---|
1895 | * @return The directory that will be the current one, the next time the |
---|
1896 | * file chooser is opened. |
---|
1897 | */ |
---|
1898 | public File getCurrentBrowsingDirectory(); |
---|
1899 | |
---|
1900 | /** |
---|
1901 | * Returns the currently choosen format for date. It must be compatible with |
---|
1902 | * the SimpleDateFormat standard Java class. |
---|
1903 | * |
---|
1904 | * @return The date format. |
---|
1905 | */ |
---|
1906 | public String getDateFormat(); |
---|
1907 | |
---|
1908 | /** |
---|
1909 | * This method indicate whether or not the debug messages must be displayed. |
---|
1910 | * Default is no debug (0). <br> |
---|
1911 | * To activate the debug, add a 'debugLevel' parameter to the applet (with 1 |
---|
1912 | * to n value), or call this method. Currently, level used in the code are |
---|
1913 | * between 0 (no debug) and 100 (max debug). <br> |
---|
1914 | * With a 0 value, no debug messages will be displayed. The |
---|
1915 | * {@link DefaultUploadPolicy}.addMsgToDebugBufferString method stores all |
---|
1916 | * debug output in a BufferString. |
---|
1917 | * |
---|
1918 | * @param debugLevel |
---|
1919 | * The new debugLevel. |
---|
1920 | * @see DefaultUploadPolicy#sendDebugInformation(String, Exception) |
---|
1921 | */ |
---|
1922 | public void setDebugLevel(int debugLevel); |
---|
1923 | |
---|
1924 | /** |
---|
1925 | * This method returns the current debug level. |
---|
1926 | * |
---|
1927 | * @return The current debug level |
---|
1928 | * @see #setDebugLevel(int) |
---|
1929 | */ |
---|
1930 | public int getDebugLevel(); |
---|
1931 | |
---|
1932 | /** |
---|
1933 | * Getter for the fileFilterName property. |
---|
1934 | * |
---|
1935 | * @return Stored value for fileFilterName |
---|
1936 | * @see UploadPolicy#PROP_FILE_FILTER_NAME |
---|
1937 | */ |
---|
1938 | public String getFileFilterName(); |
---|
1939 | |
---|
1940 | /** |
---|
1941 | * Getter for the fileChooserIconFromFileContent applet parameter. |
---|
1942 | * |
---|
1943 | * @return Stored value for fileChooserIconFromFileContent |
---|
1944 | * @see #PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT |
---|
1945 | */ |
---|
1946 | public int getFileChooserIconFromFileContent(); |
---|
1947 | |
---|
1948 | /** |
---|
1949 | * Getter for the fileChooserIconSize applet parameter. |
---|
1950 | * |
---|
1951 | * @return Stored value for fileChooserIconSize |
---|
1952 | * @see #PROP_FILE_CHOOSER_ICON_SIZE |
---|
1953 | */ |
---|
1954 | public int getFileChooserIconSize(); |
---|
1955 | |
---|
1956 | /** |
---|
1957 | * Returns the encoding that should be used for the filename. This encoding |
---|
1958 | * has no impact on the content of the file that will be uploaded. |
---|
1959 | * |
---|
1960 | * @return The encoding name, like UTF-8 (see the Charset JDK |
---|
1961 | * documentation). |
---|
1962 | */ |
---|
1963 | public String getFilenameEncoding(); |
---|
1964 | |
---|
1965 | /** |
---|
1966 | * Returns the current value for the ftpCreateDirectoryStructure applet |
---|
1967 | * parameter. |
---|
1968 | * |
---|
1969 | * @return The current value of ftpCreateDirectoryStructure |
---|
1970 | */ |
---|
1971 | public boolean getFtpCreateDirectoryStructure(); |
---|
1972 | |
---|
1973 | /** |
---|
1974 | * Returns the current value for the ftpTransfertBinary applet parameter. |
---|
1975 | * |
---|
1976 | * @return The current value of ftpTransfertBinary |
---|
1977 | */ |
---|
1978 | public boolean getFtpTransfertBinary(); |
---|
1979 | |
---|
1980 | /** |
---|
1981 | * Returns the current value for the ftpTransfertPassive applet parameter. |
---|
1982 | * |
---|
1983 | * @return The current value of ftpTransfertPassive |
---|
1984 | */ |
---|
1985 | public boolean getFtpTransfertPassive(); |
---|
1986 | |
---|
1987 | /** |
---|
1988 | * This method sets the current language to take into account. It loads the |
---|
1989 | * lang resourceBundle, which will allow the applet to display the texts in |
---|
1990 | * the correct language. |
---|
1991 | * |
---|
1992 | * @param lang |
---|
1993 | * The new language to take into account. See the |
---|
1994 | * java.util.Locale(String) constructor for a list of valid |
---|
1995 | * values. |
---|
1996 | */ |
---|
1997 | public void setLang(String lang); |
---|
1998 | |
---|
1999 | /** |
---|
2000 | * Returns the value of the applet parameter maxChunkSize (see above for a |
---|
2001 | * description of all applet parameters) |
---|
2002 | * |
---|
2003 | * @return the current value of maxChunkSize. |
---|
2004 | */ |
---|
2005 | public long getMaxChunkSize(); |
---|
2006 | |
---|
2007 | /** |
---|
2008 | * Returns the value of the applet parameter maxFileSize (see above for a |
---|
2009 | * description of all applet parameters) |
---|
2010 | * |
---|
2011 | * @return the current value of maxFileSize. |
---|
2012 | */ |
---|
2013 | public long getMaxFileSize(); |
---|
2014 | |
---|
2015 | /** |
---|
2016 | * This function returns the number of files should be uploaded during one |
---|
2017 | * access to the server. If negative or 0, all files are to be uploaded in |
---|
2018 | * one HTTP request. If positive, each HTTP upload contains this number of |
---|
2019 | * files. The last upload request may contain less files. <br> |
---|
2020 | * Examples : |
---|
2021 | * <UL> |
---|
2022 | * <li>If 1 : files are uploaded file by file. |
---|
2023 | * <li>If 5 : files are uploaded 5 files by 5 files. If 12 files are |
---|
2024 | * uploaded, 3 HTTP upload are done, containing 5, 5 and 2 files. |
---|
2025 | * </UL> |
---|
2026 | * |
---|
2027 | * @return Returns the maximum number of files, to download in one HTTP |
---|
2028 | * request. |
---|
2029 | */ |
---|
2030 | public int getNbFilesPerRequest(); |
---|
2031 | |
---|
2032 | /** |
---|
2033 | * Return the current value of readUserAgentFromNavigator |
---|
2034 | * |
---|
2035 | * @return Current value of readUserAgentFromNavigator |
---|
2036 | */ |
---|
2037 | public boolean getReadUserAgentFromNavigator(); |
---|
2038 | |
---|
2039 | /** |
---|
2040 | * Return the current value of retryMaxNumberOf |
---|
2041 | * |
---|
2042 | * @return Current value of retryMaxNumberOf |
---|
2043 | */ |
---|
2044 | public int getRetryMaxNumberOf(); |
---|
2045 | |
---|
2046 | /** |
---|
2047 | * Return the current value of retryNbSecondsBetween |
---|
2048 | * |
---|
2049 | * @return Current value of retryNbSecondsBetween |
---|
2050 | */ |
---|
2051 | public int getRetryNbSecondsBetween(); |
---|
2052 | |
---|
2053 | /** |
---|
2054 | * Return the current value of readCookieFromNavigator |
---|
2055 | * |
---|
2056 | * @return Current value of readCookieFromNavigator |
---|
2057 | */ |
---|
2058 | public boolean getReadCookieFromNavigator(); |
---|
2059 | |
---|
2060 | /** |
---|
2061 | * Get the target URL for upload. |
---|
2062 | * |
---|
2063 | * @return Should be valid URL... |
---|
2064 | */ |
---|
2065 | public String getPostURL(); |
---|
2066 | |
---|
2067 | /** |
---|
2068 | * The URL can change during the life of our policy ... |
---|
2069 | * |
---|
2070 | * @param postURL |
---|
2071 | * @throws JUploadException |
---|
2072 | */ |
---|
2073 | public void setPostURL(String postURL) throws JUploadException; |
---|
2074 | |
---|
2075 | /** |
---|
2076 | * Return the target, specified as applet parameter "afterUploadTarget" |
---|
2077 | * |
---|
2078 | * @return the specified target. |
---|
2079 | */ |
---|
2080 | public String getAfterUploadTarget(); |
---|
2081 | |
---|
2082 | /** |
---|
2083 | * HTTP protocol that should be used to send the HTTP request. Currently, |
---|
2084 | * this is mainly used by |
---|
2085 | * {@link wjhk.jupload2.policies.CoppermineUploadPolicy}, as the coppermine |
---|
2086 | * control that the protocol used for each HTTP request is the same as the |
---|
2087 | * one used during the session creation. It is used in the default policy, |
---|
2088 | * as it could be used elsewhere. <br> |
---|
2089 | * Default is : HTTP/1.1 |
---|
2090 | * |
---|
2091 | * @return The selected server protocol. |
---|
2092 | */ |
---|
2093 | public String getServerProtocol(); |
---|
2094 | |
---|
2095 | /** |
---|
2096 | * @param serverProtocol |
---|
2097 | * The protocol is set from the postURL. For HTTP URL, a HEAD |
---|
2098 | * request is done toward the server, to check if any temporary |
---|
2099 | * redirection is occuring. |
---|
2100 | */ |
---|
2101 | public void setServerProtocol(String serverProtocol); |
---|
2102 | |
---|
2103 | /** |
---|
2104 | * MD5Sum allows the server to control that the file has been correctly |
---|
2105 | * uploaded. This is interesting, when uploading in chunk mode. But |
---|
2106 | * calculating this can be long, for big files. |
---|
2107 | * |
---|
2108 | * @return true or false, whether the md5sum should be processed and sent to |
---|
2109 | * the server. |
---|
2110 | */ |
---|
2111 | public boolean getSendMD5Sum(); |
---|
2112 | |
---|
2113 | /** |
---|
2114 | * MD5Sum allows the server to control that the file has been correctly |
---|
2115 | * uploaded. This is interesting, when uploading in chunk mode. But |
---|
2116 | * calculating this can be long, for big files. |
---|
2117 | * |
---|
2118 | * @param sendMD5Sum |
---|
2119 | * true or false, whether the md5sum should be processed and sent |
---|
2120 | * to the server. |
---|
2121 | */ |
---|
2122 | public void setSendMD5Sum(boolean sendMD5Sum); |
---|
2123 | |
---|
2124 | /** |
---|
2125 | * Retrieves SSL verification mode. |
---|
2126 | * |
---|
2127 | * @return The current SSL verification mode. |
---|
2128 | */ |
---|
2129 | public int getSslVerifyCert(); |
---|
2130 | |
---|
2131 | /** |
---|
2132 | * @param showLogWindow |
---|
2133 | * The show window status to set. |
---|
2134 | * @see #getShowLogWindow() |
---|
2135 | */ |
---|
2136 | public void setShowLogWindow(String showLogWindow); |
---|
2137 | |
---|
2138 | /** |
---|
2139 | * Indicate whether the log window should be shown. It may be convenient to |
---|
2140 | * hide it, as it contains mostly debug information. But it still is the |
---|
2141 | * only place where possible errors and warnings are shown.<br> |
---|
2142 | * Default is : true |
---|
2143 | * |
---|
2144 | * @return The current value for the <i>showStatusBar</i> applet parameter. |
---|
2145 | */ |
---|
2146 | public String getShowLogWindow(); |
---|
2147 | |
---|
2148 | /** |
---|
2149 | * Returns the list of specific headers, that will be added to all HTTP |
---|
2150 | * request to the server. |
---|
2151 | * |
---|
2152 | * @return List of specific headers, with a \r\n at the end of each header. |
---|
2153 | */ |
---|
2154 | public String getSpecificHeaders(); |
---|
2155 | |
---|
2156 | /** |
---|
2157 | * Get the original name of the file on the disk. This function can encode |
---|
2158 | * the filename (see the filenameEncoding parameter). By default, the |
---|
2159 | * original filename is returned. |
---|
2160 | * |
---|
2161 | * @param fileData |
---|
2162 | * The file data whose upload file name must be calculated. |
---|
2163 | * @param index |
---|
2164 | * index of the file in the current request to the server (from 0 |
---|
2165 | * to n) |
---|
2166 | * @return The filename the is given in the filename part of the |
---|
2167 | * Content-Disposition header. |
---|
2168 | * @throws JUploadException |
---|
2169 | */ |
---|
2170 | public String getUploadFilename(FileData fileData, int index) |
---|
2171 | throws JUploadException; |
---|
2172 | |
---|
2173 | /** |
---|
2174 | * Get an upload filename, that is to be send in the HTTP upload request. |
---|
2175 | * This is the name part of the Content-Disposition header. That is: this is |
---|
2176 | * the name under which you can manage the file (for instance in the |
---|
2177 | * _FILES[$name] in PHP) and not the filename of the original file. <BR> |
---|
2178 | * If you're using one of the core JUpload {@link UploadPolicy}, the value |
---|
2179 | * for this parameter is controled by the applet parameters: |
---|
2180 | * targetPictureFormat and keepOriginalFileExtensionForConvertedImages. |
---|
2181 | * |
---|
2182 | * @param fileData |
---|
2183 | * The file data whose upload name must be calculated. |
---|
2184 | * @param index |
---|
2185 | * index of the file in the current request to the server (from 0 |
---|
2186 | * to n) |
---|
2187 | * @return The name part of the Content-Disposition header. |
---|
2188 | * @throws JUploadException |
---|
2189 | * @see #getUploadFilename(FileData, int) |
---|
2190 | */ |
---|
2191 | public String getUploadName(FileData fileData, int index) |
---|
2192 | throws JUploadException; |
---|
2193 | |
---|
2194 | /** |
---|
2195 | * Returns the current URL where error log must be posted. See <a |
---|
2196 | * href="#parameters">Parameters</a> |
---|
2197 | * |
---|
2198 | * @return the urlToSendErrorTo |
---|
2199 | */ |
---|
2200 | public String getUrlToSendErrorTo(); |
---|
2201 | |
---|
2202 | /** |
---|
2203 | * @param urlToSendErrorTo |
---|
2204 | * the urlToSendErrorTo to set |
---|
2205 | * @throws JUploadException |
---|
2206 | */ |
---|
2207 | public void setUrlToSendErrorTo(String urlToSendErrorTo) |
---|
2208 | throws JUploadException; |
---|
2209 | |
---|
2210 | /** |
---|
2211 | * Retrieve the regular expression that will be tested against each line of |
---|
2212 | * the server answer. If one line matches this expression, that upload is |
---|
2213 | * marked as failed. <br> |
---|
2214 | * |
---|
2215 | * @return The regular expression that must be run again each line of the |
---|
2216 | * http answer. |
---|
2217 | */ |
---|
2218 | public String getStringUploadError(); |
---|
2219 | |
---|
2220 | /** |
---|
2221 | * Get the regular expression that will be tested against each line of the |
---|
2222 | * server answer. If one line matches this expression, that upload is marked |
---|
2223 | * as successful. <br> |
---|
2224 | * The upload works this way: |
---|
2225 | * <ol> |
---|
2226 | * <li>Upload the selected file(s) to the server |
---|
2227 | * <li>Get all the server HTTP response. |
---|
2228 | * <li>The stringUploadSuccess regular expression is tested against each |
---|
2229 | * line from the server. |
---|
2230 | * <li>If the above test gives a match, the upload is marked as successful. |
---|
2231 | * Else, the upload is marked as unsuccessful, and a |
---|
2232 | * JUploadExceptionUploadFailure is thrown. |
---|
2233 | * </ol> |
---|
2234 | * |
---|
2235 | * @return The regular expression that must be run again each line of the |
---|
2236 | * http answer. |
---|
2237 | */ |
---|
2238 | public String getStringUploadSuccess(); |
---|
2239 | |
---|
2240 | /** |
---|
2241 | * Retrieve the regular expression that will be tested against each line of |
---|
2242 | * the server answer. If one line matches this expression, a warning message |
---|
2243 | * is displayed to the user. <br> |
---|
2244 | * |
---|
2245 | * @return The regular expression that must be run again each line of the |
---|
2246 | * http answer. |
---|
2247 | * @see #getStringUploadError() |
---|
2248 | * @see #getStringUploadSuccess() |
---|
2249 | */ |
---|
2250 | public String getStringUploadWarning(); |
---|
2251 | |
---|
2252 | /** |
---|
2253 | * Retrieve the applet's "formdata" parameter. |
---|
2254 | * |
---|
2255 | * @return The applet's formdata parameter. |
---|
2256 | */ |
---|
2257 | public String getFormdata(); |
---|
2258 | |
---|
2259 | /** |
---|
2260 | * Retrieve the applet's "httpUploadParameterName" parameter. |
---|
2261 | * |
---|
2262 | * @return The applet's httpUploadParameterName parameter. |
---|
2263 | */ |
---|
2264 | public String getHttpUploadParameterName(); |
---|
2265 | |
---|
2266 | /** |
---|
2267 | * Retrieve the applet's "httpUploadParameterType" parameter. |
---|
2268 | * |
---|
2269 | * @return The applet's httpUploadParameterType parameter. |
---|
2270 | */ |
---|
2271 | public String getHttpUploadParameterType(); |
---|
2272 | |
---|
2273 | // ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
2274 | // /////////////////// miscellaneous methods |
---|
2275 | // ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
2276 | |
---|
2277 | /** |
---|
2278 | * Reaction by the upload policy, once the management of the dropped file(s) |
---|
2279 | * is finished, that is: after all the dropped files have been successfully |
---|
2280 | * added to the file list. |
---|
2281 | * |
---|
2282 | * @param dropEvent |
---|
2283 | * The event containing the dropped file |
---|
2284 | */ |
---|
2285 | public void afterFileDropped(DropTargetDropEvent dropEvent); |
---|
2286 | |
---|
2287 | // MANAGEMENT OF THE FILE CHOOSER |
---|
2288 | |
---|
2289 | /** |
---|
2290 | * The creation of the file chooser is controled by the upload policy, to |
---|
2291 | * allow fine control of the way to select files. For instance, the |
---|
2292 | * {@link PictureUploadPolicy} creates a file chooser, and add an accessory |
---|
2293 | * to preview pictures. |
---|
2294 | * |
---|
2295 | * @return Return the specific file choose, according to this upload policy. |
---|
2296 | */ |
---|
2297 | public JUploadFileChooser createFileChooser(); |
---|
2298 | |
---|
2299 | /** |
---|
2300 | * This methods is called by the {@link JUploadFileFilter#accept(File)}. It |
---|
2301 | * allows the current upload policy to filter files, according to any |
---|
2302 | * choosen applet behaviour. This filter applied only when using the |
---|
2303 | * fileChooser. Files dropped onto the applet won't trigger this function.<br> |
---|
2304 | * In the {@link DefaultUploadPolicy} upload policy, this filter is based on |
---|
2305 | * the applet parameter: <i>allowedFileExtensions</i>. |
---|
2306 | * |
---|
2307 | * @param file |
---|
2308 | * Allows the applet to filter files from the file chooser. |
---|
2309 | * @return true or false, whether the file is accepted or not. |
---|
2310 | * @see JUploadPanel |
---|
2311 | */ |
---|
2312 | public boolean fileFilterAccept(File file); |
---|
2313 | |
---|
2314 | /** |
---|
2315 | * Return a description for the FileFilter, according to the current upload |
---|
2316 | * policy. |
---|
2317 | * |
---|
2318 | * @return A description for the current filter |
---|
2319 | */ |
---|
2320 | public String fileFilterGetDescription(); |
---|
2321 | |
---|
2322 | /** |
---|
2323 | * Response for the {@link JUploadFileView#getIcon(File)}. Default is |
---|
2324 | * implemented in {@link DefaultUploadPolicy#fileViewGetIcon(File)}, by |
---|
2325 | * returning null, which displays the default icon. |
---|
2326 | * |
---|
2327 | * @param file |
---|
2328 | * The file from which the icon should represent. |
---|
2329 | * @return The resulting icon. |
---|
2330 | */ |
---|
2331 | public Icon fileViewGetIcon(File file); |
---|
2332 | |
---|
2333 | /** |
---|
2334 | * This method changes the current mouse cursor to the wait one. It returns |
---|
2335 | * the old one so that, it can be restored, once the work is done. |
---|
2336 | * |
---|
2337 | * @return The cursor that was active, before changing to the wait one. |
---|
2338 | * @see #setCursor(Cursor) |
---|
2339 | */ |
---|
2340 | public Cursor setWaitCursor(); |
---|
2341 | |
---|
2342 | /** |
---|
2343 | * Changes the current mouse cursor. This method can be called at the end of |
---|
2344 | * a big treatement, to restore the cursor returned by the |
---|
2345 | * {@link #setWaitCursor()}. |
---|
2346 | * |
---|
2347 | * @param cursor |
---|
2348 | * The cursor that must be set. |
---|
2349 | * @return The cursor that was active before setting the new one. Can be |
---|
2350 | * used to restore its previous state. |
---|
2351 | */ |
---|
2352 | public Cursor setCursor(Cursor cursor); |
---|
2353 | |
---|
2354 | // ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
2355 | // DISPLAY OF MESSAGES (ERROR, DEBUG ...) |
---|
2356 | // ////////////////////////////////////////////////////////////////////////////////////////////// |
---|
2357 | |
---|
2358 | /** |
---|
2359 | * This method allows the applet to post debug information to the website |
---|
2360 | * (see {@link #getUrlToSendErrorTo()}). Then, it is possible to log the |
---|
2361 | * error, to send a mail... |
---|
2362 | * |
---|
2363 | * @param reason |
---|
2364 | * A string describing briefly the problem. The mail subject will |
---|
2365 | * be something like: Jupload Error (reason) |
---|
2366 | * @param exception |
---|
2367 | * The java exception that was raised, or null if no exception. |
---|
2368 | */ |
---|
2369 | public void sendDebugInformation(String reason, Exception exception); |
---|
2370 | |
---|
2371 | /** |
---|
2372 | * log an error message, based on an exception. Will be logged in the log |
---|
2373 | * window, if defined. <BR> |
---|
2374 | * The dialog box will only contain an Ok button. Same as caling: |
---|
2375 | * displayErr(e, JOptionPane.OK_OPTION); |
---|
2376 | * |
---|
2377 | * @param e |
---|
2378 | * The exception to report |
---|
2379 | */ |
---|
2380 | public void displayErr(Exception e); |
---|
2381 | |
---|
2382 | /** |
---|
2383 | * log an error message, based on an exception. Will be logged in the log |
---|
2384 | * window, if defined.<BR> |
---|
2385 | * |
---|
2386 | * @param err |
---|
2387 | * The erreur message to be displayed. If null the exception (or |
---|
2388 | * it's cause if any) message is displayed. |
---|
2389 | * @param e |
---|
2390 | * The exception to report |
---|
2391 | * @param optionType |
---|
2392 | * One of the valid {@link JOptionPane} option types for the |
---|
2393 | * {@link JOptionPane#showConfirmDialog(java.awt.Component, Object, String, int)} |
---|
2394 | * method: OK_CANCEL_OPTION, YES_NO_OPTION, |
---|
2395 | * YES_NO_CANCEL_OPTION... -1 is also accepted, to only have the |
---|
2396 | * Ok button. OK_OPTION is prohibited, as it has the same value |
---|
2397 | * as YES_NO_OPTION. |
---|
2398 | * @return The XXX_OPTION, corresponding to the button clicked by the user. |
---|
2399 | */ |
---|
2400 | public int displayErr(String err, Exception e, int optionType); |
---|
2401 | |
---|
2402 | /** |
---|
2403 | * log an error message. Will be logged in the log window, if defined. <BR> |
---|
2404 | * The dialog box will only contain an Ok button. |
---|
2405 | * |
---|
2406 | * @param err |
---|
2407 | * The erreur message to be displayed. |
---|
2408 | */ |
---|
2409 | public void displayErr(String err); |
---|
2410 | |
---|
2411 | /** |
---|
2412 | * log an error message. Will be logged in the log window, if defined. <BR> |
---|
2413 | * The dialog box will only contain an Ok button. |
---|
2414 | * |
---|
2415 | * @param err |
---|
2416 | * The error message to be displayed. |
---|
2417 | * @param e |
---|
2418 | * An exception. It's stacktrace is logged. |
---|
2419 | */ |
---|
2420 | public void displayErr(String err, Exception e); |
---|
2421 | |
---|
2422 | /** |
---|
2423 | * log an info message. Will be logged in the log window, if defined. |
---|
2424 | * |
---|
2425 | * @param info |
---|
2426 | * The information message that will be displayed. |
---|
2427 | */ |
---|
2428 | public void displayInfo(String info); |
---|
2429 | |
---|
2430 | /** |
---|
2431 | * log a warning message. Will be logged in the log window, if defined. |
---|
2432 | * |
---|
2433 | * @param warn |
---|
2434 | * The warning message that will be displayed. |
---|
2435 | */ |
---|
2436 | public void displayWarn(String warn); |
---|
2437 | |
---|
2438 | /** |
---|
2439 | * log a debug message. Will be logged in the log window, if defined. |
---|
2440 | * |
---|
2441 | * @param debug |
---|
2442 | * The message to display. |
---|
2443 | * @param minDebugLevel |
---|
2444 | * If the current debug level is superior or equals to |
---|
2445 | * minDebugLevel, the message will be displayed. Otherwise, it |
---|
2446 | * will be ignored. |
---|
2447 | */ |
---|
2448 | public void displayDebug(String debug, int minDebugLevel); |
---|
2449 | |
---|
2450 | // Others |
---|
2451 | |
---|
2452 | /** |
---|
2453 | * Add an header to the list of headers that will be added to each HTTP |
---|
2454 | * upload request. This method is called from specific uploadPolicies, which |
---|
2455 | * would need headers to be added to all uploads. These headers are used in |
---|
2456 | * {@link wjhk.jupload2.policies.DefaultUploadPolicy}. |
---|
2457 | * |
---|
2458 | * @param header |
---|
2459 | * @see #onAppendHeader(ByteArrayEncoder) |
---|
2460 | */ |
---|
2461 | public void addHeader(String header); |
---|
2462 | |
---|
2463 | /** |
---|
2464 | * Append specific headers for this upload (session cookies, for instance). |
---|
2465 | * This method is called while building each upload HTTP request. |
---|
2466 | * |
---|
2467 | * @param sb |
---|
2468 | * The header {@link ByteArrayEncoder} where specific headers |
---|
2469 | * should be appended. |
---|
2470 | * @return The {@link ByteArrayEncoder} given in parameters. This is allows |
---|
2471 | * to work like with StringBuffer.append method: |
---|
2472 | * sb.append(s1).append(s2); |
---|
2473 | * @throws JUploadIOException |
---|
2474 | * @see #addHeader(String) |
---|
2475 | * @see wjhk.jupload2.upload.FileUploadThread |
---|
2476 | */ |
---|
2477 | public ByteArrayEncoder onAppendHeader(ByteArrayEncoder sb) |
---|
2478 | throws JUploadIOException; |
---|
2479 | |
---|
2480 | /** |
---|
2481 | * This method is called each time a file is selected in the panel files. It |
---|
2482 | * allows, for instance, to preview a picture |
---|
2483 | * {@link wjhk.jupload2.policies.PictureUploadPolicy}. |
---|
2484 | * |
---|
2485 | * @param fileData |
---|
2486 | */ |
---|
2487 | public void onFileSelected(FileData fileData); |
---|
2488 | |
---|
2489 | /** |
---|
2490 | * Reaction when the user double click on a file, in the file list. Default |
---|
2491 | * is no reaction. In {@link PictureUploadPolicy}, it will open a |
---|
2492 | * {@link PictureDialog}. |
---|
2493 | * |
---|
2494 | * @param fileData |
---|
2495 | */ |
---|
2496 | public void onFileDoubleClicked(FileData fileData); |
---|
2497 | |
---|
2498 | /** |
---|
2499 | * Execute any action, that must be done before upload. For instance, |
---|
2500 | * {@link PictureUploadPolicy} disable the rotation buttons during buttons. |
---|
2501 | * The {@link DefaultUploadPolicy#beforeUpload()} method just returns true. |
---|
2502 | * |
---|
2503 | * @return indicate if everything is ready for upload. |
---|
2504 | */ |
---|
2505 | public boolean beforeUpload(); |
---|
2506 | |
---|
2507 | /** |
---|
2508 | * This method returns true, if upload is a success. A HTTP response of "200 |
---|
2509 | * OK" indicates that the server response is techically correct. But, it may |
---|
2510 | * be a functionnal error. For instance, the server could answer by a proper |
---|
2511 | * HTTP page, that the user is no allowed to upload files. It's up to the |
---|
2512 | * uploadPolicy to check this, and answer true or false to this method. <br> |
---|
2513 | * This method is called once for each HTTP request toward the server. For |
---|
2514 | * instance, if the upload is done file by file, and there are three files |
---|
2515 | * to upload, this method will be called three times. <br> |
---|
2516 | * So this method is different from the |
---|
2517 | * {@link #afterUpload(Exception, String)}, that will be called only once in |
---|
2518 | * this case, after the three calls to the checkUploadSuccess method. |
---|
2519 | * |
---|
2520 | * @param status |
---|
2521 | * The numeric response status (e.g. 200) |
---|
2522 | * @param msg |
---|
2523 | * The status message from the first line of the response (e.g. |
---|
2524 | * "200 OK"). |
---|
2525 | * @param body |
---|
2526 | * The http body part (that is: the serverOuput without the http |
---|
2527 | * headers and the blank line that follow them). |
---|
2528 | * @return true (or an exception is raised, instead of returning false). |
---|
2529 | * This garantees that all cases are handled: the compiler will |
---|
2530 | * indicate an error if the code can come to the end of the method, |
---|
2531 | * without finding a 'return' or a throw exception. This return code |
---|
2532 | * can be ignored by the caller. |
---|
2533 | * @throws JUploadException |
---|
2534 | * Thrown if the success conditions are not met. |
---|
2535 | */ |
---|
2536 | public boolean checkUploadSuccess(int status, String msg, String body) |
---|
2537 | throws JUploadException; |
---|
2538 | |
---|
2539 | /** |
---|
2540 | * This method is called after an upload, whether it is successful or not. |
---|
2541 | * This method is called once for each click of the user on the 'upload' |
---|
2542 | * button. That is: if the nbFilesPerRequest is 2, and the user selected 5 |
---|
2543 | * files before clicking on the 'upload' button. Then the afterUpload is |
---|
2544 | * called once the 5 files were uploaded to the server. |
---|
2545 | * |
---|
2546 | * @param e |
---|
2547 | * null if success, or the exception indicating the problem. |
---|
2548 | * @param serverOutput |
---|
2549 | * The full server output, including the HTTP headers. |
---|
2550 | * @throws JUploadException |
---|
2551 | */ |
---|
2552 | public void afterUpload(Exception e, String serverOutput) |
---|
2553 | throws JUploadException; |
---|
2554 | |
---|
2555 | /** |
---|
2556 | * Returns the current locale. It is the default value at startup, based on |
---|
2557 | * the local computer configuration. Then, if the lang applet parameter is |
---|
2558 | * given, this method the Locale initialized from this lang parameter. |
---|
2559 | * |
---|
2560 | * @return The current Locale for the current policy. |
---|
2561 | */ |
---|
2562 | public Locale getLocale(); |
---|
2563 | |
---|
2564 | /** |
---|
2565 | * Retrieve a lang string, based on the file cointained in the |
---|
2566 | * wjhk.jupload2.lang package. This allows localization. |
---|
2567 | * |
---|
2568 | * @param key |
---|
2569 | * The key, whose associated text is to retrieve. This text must |
---|
2570 | * respect the constraints of the |
---|
2571 | * {@link String#format(String, Object...)} method, that is |
---|
2572 | * called in the |
---|
2573 | * {@link DefaultUploadPolicy#getLocalizedString(String, Object...)} |
---|
2574 | * implementation of this method. |
---|
2575 | * @param args |
---|
2576 | * The optional parameters, that will replace the placeholders in |
---|
2577 | * the localized text identified by 'key'. |
---|
2578 | * @return The associated text. |
---|
2579 | */ |
---|
2580 | public String getLocalizedString(String key, Object... args); |
---|
2581 | |
---|
2582 | /** |
---|
2583 | * Displays a MessageBox with a unique 'Ok' button, by calling the |
---|
2584 | * {@link JOptionPane#showMessageDialog(java.awt.Component, Object)} method. |
---|
2585 | * |
---|
2586 | * @param key |
---|
2587 | * The string identifying the text to display, depending on the |
---|
2588 | * current language. |
---|
2589 | * @see #alertStr(String) |
---|
2590 | */ |
---|
2591 | public void alert(String key); |
---|
2592 | |
---|
2593 | /** |
---|
2594 | * Displays a MessageBox with a unique 'Ok' button, by calling the |
---|
2595 | * {@link JOptionPane#showMessageDialog(java.awt.Component, Object)} method. |
---|
2596 | * |
---|
2597 | * @param str |
---|
2598 | * The full String that must be displayed to the user. |
---|
2599 | * @see #alert(String) |
---|
2600 | */ |
---|
2601 | public void alertStr(String str); |
---|
2602 | |
---|
2603 | /** |
---|
2604 | * Displays a MessageBox with a unique 'Ok' button, by calling the |
---|
2605 | * {@link JOptionPane#showConfirmDialog(java.awt.Component, Object, String, int)} |
---|
2606 | * method. |
---|
2607 | * |
---|
2608 | * @param str |
---|
2609 | * The full String that must be displayed to the user. |
---|
2610 | * @param optionTypes |
---|
2611 | * The options indicating the button to display. Valid options |
---|
2612 | * are the options valid for the |
---|
2613 | * {@link JOptionPane#showConfirmDialog(java.awt.Component, Object, String, int)} |
---|
2614 | * method. |
---|
2615 | * @return The JOptionConstant that indicates the button the user cliecked |
---|
2616 | * on (for instance OK_OPTION) |
---|
2617 | * @see #alert(String) |
---|
2618 | */ |
---|
2619 | public int confirmDialogStr(String str, int optionTypes); |
---|
2620 | |
---|
2621 | /** |
---|
2622 | * Indicates that an error occurs. |
---|
2623 | * |
---|
2624 | * @return The last Exception that occurs in the applet. null if no |
---|
2625 | * exception occurs. |
---|
2626 | */ |
---|
2627 | public JUploadException getLastException(); |
---|
2628 | |
---|
2629 | /** |
---|
2630 | * Retrieve the body of the last server response. |
---|
2631 | * |
---|
2632 | * @return The string containing the last server response (body); |
---|
2633 | */ |
---|
2634 | public String getLastResponseBody(); |
---|
2635 | |
---|
2636 | /** |
---|
2637 | * Retrieve the status/error message of the last server response. |
---|
2638 | * |
---|
2639 | * @return The string containing either the last server status or (if the |
---|
2640 | * error regex matches, the parsed error message. |
---|
2641 | */ |
---|
2642 | public String getLastResponseMessage(); |
---|
2643 | } |
---|