// // $Id: UploadPolicy.java 287 2007-06-17 09:07:04 +0000 (dim., 17 juin 2007) // felfert $ // // jupload - A file upload applet. // Copyright 2007 The JUpload Team // // Created: 2006-05-04 // Creator: etienne_sf // Last modified: $Date: 2010-08-18 08:23:24 -0300 (Qua, 18 Ago 2010) $ // // This program is free software; you can redistribute it and/or modify it under // the terms of the GNU General Public License as published by the Free Software // Foundation; either version 2 of the License, or (at your option) any later // version. This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more // details. You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software Foundation, Inc., // 675 Mass Ave, Cambridge, MA 02139, USA. package wjhk.jupload2.policies; import java.awt.Cursor; import java.awt.dnd.DropTargetDropEvent; import java.io.File; import java.util.Locale; import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JProgressBar; import javax.swing.filechooser.FileFilter; import wjhk.jupload2.context.JUploadContext; import wjhk.jupload2.exception.JUploadException; import wjhk.jupload2.exception.JUploadExceptionStopAddingFiles; import wjhk.jupload2.exception.JUploadIOException; import wjhk.jupload2.filedata.FileData; import wjhk.jupload2.gui.JUploadFileChooser; import wjhk.jupload2.gui.JUploadFileFilter; import wjhk.jupload2.gui.JUploadFileView; import wjhk.jupload2.gui.JUploadPanel; import wjhk.jupload2.gui.image.PictureDialog; import wjhk.jupload2.upload.helper.ByteArrayEncoder; /** * This package contains upload policies, which allow easy configuration of the * applet behavior.
*
* The class {@link DefaultUploadPolicy} contains a default implementation for * all UploadPolicy methods.
*
*

Parameters

*

* Here is the list of all parameters available in the current package, that is: * available in available upload policies. These are applet parameters that can * be 'given' to the applet, with tags, as explained below in the example. *

*

* Let's start with some hints:

*
  • debugLevel and showLogWindow: I recommend putting debugLevel to 99 * and showLogWindow to onError. *
  • maxFileSize: this prevents the user to upload * too big files. The value depends on your needs. *
  • maxChunkSize: allows you to override the * server's maximum upload file size. The uploaded file will be split in pieces * of maxChunkSize bytes. Then, it's up to you to concatenate the file pieces, * into a server script. There are sample in this doc, and in the JUpload wiki. * Please add your samples also...
  • *

    * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Contains the name of the file filter, as it will be displayed in the drop * down list of filters, in the file chooser. If this name is given to the * applet, it will be returned by the {@link FileFilter#getDescription()} * method.
    * Default value for applet parameter "fileFilterName". This default value let * the {@link DefaultUploadPolicy} return a calculated name, which contains the * list of allowed file extensions.
    * Note: this parameter is ignored, if there is no file filter, that is, if the * allowedFileExtensions applet parameter is not used. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Note 6 (security): take care that the full URL is visible, if the user * take a look at the page source. So, you should take care when putting login * and password there. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
    Parameter nameDefault value /
    * Implemented in
    Description
    afterUploadTarget
    * Since 2.9.2rc4
    _self
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter allows to select a specific target frame when redirecting * to afterUploadURL. The following values are possible:
    *
      *
    • _self - Show in the window and frame that contain the * applet.
    • *
    • _parent - Show in the applet's parent frame. If the applet's * frame has no parent frame, acts the same as _self.
    • *
    • _top - Show in the top-level frame of the applet's window. * If the applet's frame is the top-level frame, acts the same as _self.
    • *
    • _blank - Show in a new, unnamed top-level window. *
    • name - Show in the frame or window named name. If a target * named name does not already exist, a new top-level window with the * specified name is created, and the document is shown there.
    • *
    * See also: * {@link java.applet.AppletContext#showDocument(java.net.URL, java.lang.String)} *
    afterUploadURLnull
    * since 2.9.0
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter is used by all policies. It allows the applet to change * the current page to another one after a successful upload.
    * This allows, for instance, to display a page containing the file description * of the newly uploaded page. Since version 3.0.2b2, you can specify a * JavaScript expression instead of a plain URL. So afterUploadURL can now * contain:
    *
      *
    • A javascript expression: The URL must start by javascript:. * See below for details.
    • *
    • A http URL: the navigator will open this URL, in the current page * or another, according to the afterUploadTarget parameter. Any URL that * doesn't start by javascript: is handled as an http URL.
    • *
    * If the value of afterUploadURL starts with the string "javascript:", the * remainder of the string is evaluated as JavaScript expression in the current * document context. For example: If afterUloadURL is
    * "javascript:alert('Thanks for the upload');",
    then after a * successful upload, a messagebox would pop up. Since 3.0.2b3 there are now * three place holders available which can be used as parameters in function * calls: *
      *
    • %success% is replaced by true or false * depending on upload success. *
    • %msg% is replaced by an unquoted string, containing the * error message received from the server (if any). Inside that string, all * occurrences of the single-quote character (hex 27) are quoted by backslashes. *
    • %body% is replaced by an unquoted string, containing the * complete response body. Inside that string, all occurrences of the * single-quote character (hex 27) are quoted by backslashes. *
    * So if you set afterUloadURL to "javascript:alert('%body%');", * then the resulting message box will show the body content of the last server * response.
    albumId-1
    *
    * {@link wjhk.jupload2.policies.CoppermineUploadPolicy}
    This parameter is only used by CoppermineUploadPolicy. So it is to be * used to upload into a coppermine * picture gallery. This parameter contains the identifier of the album, * where pictures should be used. See CoppermineUploadPolicy for an example.
    * Before upload, CoppermineUploadPolicy. * {@link wjhk.jupload2.policies.CoppermineUploadPolicy#beforeUpload()} checks * that the albumId is correct, that is: >=1.
    allowedFileExtensionsempty string
    * since 2.9.0
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter allows the caller to specify a list of file extension. If * this parameter is specified, only file with this extension can be selected in * the applet.
    * This parameter must contains a list of extensions, in lower case, separated * by slashes. eg: jpg/jpeg/gif
    allowHttpPersistentfalse
    * since 3.0.0rc1
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter allows to switch off persistent HTTP connections which are * enabled by default (and the protocol version allows it). Currently, we * encountered problems with persistent connections when testing on a windows * box using a loopback interface only.
    * Note: default value changed to false in 4.0 version.
    browsingDirectorynull
    * since 4.0.0b2
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter allows to control the starting browsing directory, that * is, the directory the is the current one when the file chooser is open.
    * Notes: *
      * If the directory doesn't exist, or can not be read, a warning is written on * the local log window (visible only in debug mode), and this parameter is * ignored. *
        * This directory may begin with ~/ or ~\, to have a path set relative to the * current user's home.
    *
    debugLevel0
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    With 0, you get the normal production output. The higher the number is, * the more information is displayed in the log window. Here are some hints * about debug level values (please note that this is indicative ... including * for me, as I'me writing this during 3.3.2 release: *
  • 0: No debug output. Only INFO and ERROR *
  • 10: Structural debug output (entering method, exception info...) *
  • 30: Details about method parameters *
  • 50: Details about internal method variables. *
  • 70: Details about encoding toward the server *
  • 80: Details about server's response *
  • 90: Details about query and server response when sending debug output to * urlToSendErrorTo *
  • 100: Maximum output information level. The redirection toward * afterUploadURL is blocked *
  • >100: Additional things for internal debug, like some wait in the code to * check what messages the applet displays, while uploading small files on * localhost.

  • * Note: All debug messages are stored in a temporary log file. This can be used * to display more information, if needed. See also the urlToSendErrorTo * applet parameter.
    fileChooserIconFromFileContent0
    * since 3.1.0b
    * {@link wjhk.jupload2.policies.UploadPolicy}
    This parameter allows to control whether the file icons in the file * chooser are calculated from the file content. This is currently only * available for pictures.
    * If activated, the file chooser will open each pictures, and calculate the * icon by resizing the picture. This is done in by using thread of minimam * priority, to minimize performances impact on the navigator. Available values * are: *
  • -1: disabled. The default system are used. *
  • 0 (default): available only in picture mode. That is: the current upload * policy is an instance of or a class inheriting from * {@link PictureUploadPolicy} *
  • 1: available for all upload policies.
  • fileChooserIconSize20
    * since 3.1.0b
    * {@link wjhk.jupload2.policies.UploadPolicy}
    This parameter allows to control the size of icons, in pixels, in the * file chooser. Used only when fileChooserIconFromFileContent is activated.
    * Note: The standard icon size is a value of 20. With 50, you'll get a better * view of the picture.
    fileChooserImagePreviewtrue
    * since 3.1.0b
    * {@link wjhk.jupload2.policies.PictureUploadPolicy}
    This parameter allows to control whether an preview is available for * picture in the file chooser. If activated, the file chooser will open the * preview in a separate thread, of high priority. This avoid blocking the * applet while calculating the preview picture, when the user just * double-clicked a picture file. This parameter is ignored for * DefaultUploadPolicy. *
    fileFilterNamenull
    * since 5.0.0
    *
    filenameEncodingnull
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    Since 3.3.0, this parameter is no more used. The full applet upload HTTP * request to the server is now correctly encoded.
    * With null, the filename in the Content-Disposition header is not * encoded. If not null, the applet tries to encode this filename with the given * encoding. It's up to the receiver (the web site) to decode this encoding (see * {@link #getUploadFilename(FileData, int)}.
    * Example: if the "UTF8" encoding is chosen, the PHP function urldecode can be * used to decode the filename.
    formdatanull
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    * Since 2.9.2rc4
    With this parameter, the name of a HTML form can be specified. If the * specified form exists in the same document like the applet, all all * form-variables are added as POST parameters to the applet's POST request.
    * Note: Whatever value is in the httpUploadParameterType applet * parameter, these parameters with the name of the given input in the form. * That is: if you have an input text named 'myText', there will be one myText * parameter in the HTTP upload request, with the text/plain mime type, and * whose value is the content of this field, in the form.
    ftpCreateDirectoryStructurefalse
    * since 4.2.0
    * {@link wjhk.jupload2.policies.UploadPolicy}
    This parameter allows to control whether the directory structure on the * client side must be created on the server side.
    * Example: if the user upload the test/ directory, which contains the * readme.txt file. With ftpCreateDirectoryStructure to false (or default * value), the readme.txt is uploaded in the postURL directory. If set to true, * the test/ folder is created as a subfolder of the path given in the postURL * directory, and the readme.txt is uploaded in this subfolder.
    * Note: in HTTP upload, the pathinfo and relpathinfo allows the server side * script to manage this directory structure.
    ftpTransfertBinarytrue
    * since 4.1.0
    * {@link wjhk.jupload2.policies.UploadPolicy}
    This parameter allows to control whether the upload should be done in * binary or ascii mode. Default is to upload in binary mode.
    ftpTransfertPassivetrue
    * since 4.1.0
    * {@link wjhk.jupload2.policies.UploadPolicy}
    This parameter allows to control whether the upload should be done in FTP * passive mode, or in active mode (where the FTP server opens a connection to * the client, to do the upload). Default passive mode.
    highQualityPreviewfalse
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    If this parameter is set to true, the applet will call the * BufferedImage.getScaledInstance(), instead of doing a basic scale * transformation. This consume more CPU: on a PII 500MHz, the full screen go * from around 5 seconds to between 12 and 20 seconds, for a picture created by * my EOS20D (8,5M pixels). The standard preview (above the file list) seem to * be displayed at the same speed, whatever is the value of this parameter.
    * Note: when resizing is done before upload, the * BufferedImage.getScaledInstance() is always called, so that the uploaded * picture is of the best available quality.
    httpUploadParameterNameFile
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    * since 4.5.0
    Contains the parameter name, that will be used to send the file in the * HTTP upload request. The default value (File), associated with the default * value for httpUploadParameterType (see below), makes all file be uploaded * with name from File0 to FileN (when there are N+1 file to upload).
    * Put another value, of your server part script need a particular parameter * name to work properly.
    * Note: valid characters for this parameter are: first letter (letter or * number), next letters (letter, number or underscore)
    httpUploadParameterTypeiteration
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    * since 4.5.0
    Allowed values are: *
  • iteration: Used to have the attribute property that actually * contains the file be named File0 to FileN (if you have N+1 uploaded files). * This is the default behavior. In this case, your server script should look * for POST properties, named 'File0' to 'FileN'
  • *
  • array: Used if your server script want to receive one array, that * will contain all uploaded files.
  • *
  • oneFile: Indicates that, in the HTTP upload request, there will be * only one file. This value is only valid when nbFilesPerRequest is 1. The * parameters in the HTTP upload request are let untransformed. For instance, if * httpUploadParameterName is the default value (File), the file content will be * loaded under the HTTP parameter 'File' (not File0 or File[]).

  • * Note: All parameters common to all pictures are sent directly. For * instance, if toto is given on the URL, the toto parameter is sent as is (no * toto0 for iteration or toto[] for array). Also, if you use the * formdata applet parameter, these parameters are sent as is (no 0 or [] * added to the parameter name).
    keepOriginalFileExtensionForConvertedImagesfalseis only relevant, if targetPictureFormat is specified.
    *
      *
    • false (default):
      * If you upload the file 'test.png' and it is converted to 'jpg', the * fileextension will be changed, so that the server will receive this filename: * 'test.jpg'
    • *
    • true:
      * If you upload the file 'test.png' and it is converted to 'jpg', the * fileextension will NOT be changed, so that the server will receive the * original filename: 'test.png'
    • *
    *
    langNavigator language
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    Should be something like en, fr... Currently only French * and English are known from the applet. If anyone want to add another language * ... Please translate the wjhk.jupload2.lang.lang_en, and send it back to * .
    lookAndFeel
    * since 2.5
    empty
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This allows to control the look & feel of the applet. The authorized * values are: *
      *
    • empty: uses the default look & feel. This is the same as java. *
    • java: uses the java default look & feel. Same as empty. *
    • system: uses the current system look and feel. The call will be :
      * UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); *
    • Any valid String argument for UIManager.setLookAndFeel(String). *
    *
    maxChunkSize
    * Since 2.7.1
    0
    * Long.MAX_VALUE
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameters defines the maximum size of an upload. *
      *
    • If not set, or set to a value of 0 or less, the chunk mode is disabled. * That is: each file will be uploaded within being split in pieces. *
    • If set to a value of 1 or more, the upload size will be never be more * than maxChunkSize. A file bigger will be split in several part of * maxChunkSize size, then the last part will contain the remaining, and * will probably be smaller than maxChunkSize. *
    *
    * How to build the server part: the server will have to 'guess' that the * file is split, and then it will have to reconstruct the uploaded file. Here * are the necessary informations: *
      *
    • When a file is chunked, the jupart and jufinal parameter * are given in the URL (get parameters). This identify a chunk upload. If these * parameters are not given, the file(s) is(are) uploaded in one piece. *
    • jupart identify the part number: from 1 to N for a file being * split in N pieces. The N-1 chunks should be maxChunkSize bytes long. * The last one contains the remaining of the file. *
    • jufinal is set to 0 for chunks from 1 to N-1. It is is set to 1 * only for the last chunk (N, in this 'example'). *
    • The uploaded filename is not modified when the upload is chunked. * Example: upload of the file bigPicture.jpeg, of 4,5 Mb, with chunk of * 2Mb. The upload is split in three chunk. Chunk 1 and 2 are 2Mb long. The * third one is 0,5Mb long. The uploaded filename for these three uploads is * bigPicture.jpeg. It's up to the server part to read the jupart * and jufinal get parameters, to understand that the upload is chunked. *
    • Important: The server script must check the resulting * filesize. If not, the client can send a file of any size, and fill the server * hard drive. *
    • The wwwroot/pages/parseRequest.jsp is a java example of a server page * that can receive chunk upload. It stores each chunk is filename.partN * (where N is the chunk number), then construct the final file, by * concatenating all parts together. *
    * Note: If nbFilesPerRequest is different than 1, the applet will try * to upload the files until the sum of their content length is less than * maxChunkSize. The upload is triggered just before the sum of their content * length is bigger then maxChunkSize.
    * If one file is bigger than maxChunkSize, all previous files are * uploaded (at once or not, depending on nbFilesPerRequest). Then the 'big' * file is uploaded alone, split in chunk. Then upload goes on, file by file or * not, depending on nbFilesPerRequest.
    maxFileSize
    * Since 2.7.1
    0
    * Long.MAX_VALUE
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter identify the maximum size that an uploaded file may have. * It prevent the user to upload too big files. It is especially important when * chunk upload is activated (see below maxChunkSize). *
      *
    • If maxChunkSize is not set, negative or 0, maxFileSize * should be the maximum upload size of the server. In this case, it is useful * only to display a message when the user select a file that will be refused by * the server. *
    • If chunk upload is activated, this parameter becomes really important: in * this case the maximum file size of an uploaded file is ... the available * space on the server hard drive! (see below, maxChunkSize). *
    *
    maxPicHeightSince 3.3.0: Integer.MAX_VALUE
    * (was -1)
    *
    * {@link wjhk.jupload2.policies.PictureUploadPolicy}
    This parameters allows the HTML page to control the maximum height for * pictures. If a picture is to be download, and its height is bigger, the * picture will be resized. The proportion between width and height of the * resized picture are the same as those of the original picture. If both * maxPicHeight and maxPicWidth are given, it can happen that the resized * picture has a height lesser than maxPicHeight, so that width is no more than * maxPicWidth.
    * Precisions:
    * If this parameter value is negative or 0, then no control is done on the * picture height.
    * If the original picture is smaller than the maximum size, the picture is not * enlarged.
    * If the picture is resized, its other characteristics are kept (number of * colors, ColorModel...). The picture format is kept, if targetPictureFormat is * empty. If the picture format is a destructive (like jpeg), the maximum * available quality is chosen.
    * See also maxPicWidth, realMaxPicHeight
    maxPicWidthSince 3.3.0: Integer.MAX_VALUE
    * (was -1)
    *
    * {@link wjhk.jupload2.policies.PictureUploadPolicy}
    Same as maxPicHeight, but for the maximum width of the uploaded picture. *
    * See also maxPicHeight, realMaxPicWidth
    nbFilesPerRequest1 since 4.3.0
    * (was -1)
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This allows the control of the maximal number of files that are uploaded * in one HTTP upload to the server.
    * If set to less than 1 (0 or negative), there is no maximum. This means that all files are uploaded in * the same HTTP request.
    * If set to 5, for instance, and there are 6 files to upload, there will be two * HTTP upload request to the server : 5 files in the first one, and that last * file in a second HTTP request.
    pictureCompressionQuality0.8
    * since 3.1.0
    * {@link wjhk.jupload2.policies.PictureUploadPolicy}
    This parameter controls the picture compression quality, when writing the * picture file. 1 means high quality picture, but big files. 0 means poor * quality pictures, but small files. 0.8 is a good compromise for the web.
    * It is different from the highQualityPreview, which controls the way picture * are resized in memory.
    * This parameter is currently applied only to jpg (and jpeg) pictures.
    pictureTransmitMetadatafalse since 3.3.0
    * (was true before)

    * since 3.2.0
    * {@link wjhk.jupload2.policies.PictureUploadPolicy}
    This parameter controls whether the applet transmit metadata of the * original picture. This may prevent personal information to be thrown on the * net.
    * Note 1: This parameter is especially important for picture coming from the * Canon EOS 20D, 30D and 40D: pictures shooted in portrait mode contain * metadata that are incompatible with Java 1.6.0_3! The colors of transformed * pictures become strange... Since 3.3.0: default to false, to avoid * this annonying (and currently not explained) problem.
    * Note 2: As of 3.2.0, this parameter blocks metadata only for * pictures that are updated by the applet. Metadata from picture transmitted * 'as is' are not removed. This is corrected in 3.3.0.
    postURLnull since 1.9.2rc4, (was Mandatory before)
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter specifies the target URL toward which the files should be * uploaded. Since version 1.9.2rc4 this parameter is not mandatory anymore. * Instead, if omitted or a relative URL is given, the resulting URL is * constructed from the applet's DocumentBaseURL. This means, that if the applet * tag is dynamically constructed from a PHP script without specifying * postURL, the same same script receives the subsequent * POST request(s). If this URL may change during the applet execution time, you * can call the setProperty applet method from javascript, or create a new * UploadPolicy class and either : *
      *
    • Override the {@link wjhk.jupload2.policies.UploadPolicy#getPostURL()} * method, to make the postURL totaly dynamic. *
    • Override the * {@link wjhk.jupload2.policies.UploadPolicy#setPostURL(String)} method, to * modify the postURL on the fly, when it is changed. *
    • Override the * {@link wjhk.jupload2.policies.UploadPolicy#setProperty(String, String)} * method. The {@link wjhk.jupload2.policies.CoppermineUploadPolicy} changes the * postURL when the albumID property changes. *
    • Find another solution ... *
    * Note 1: in HTTP, the upload is done in the same user session, as the * applet uses the cookies from the navigator. This allows right management * during upload, on the server side.
    * Note 2: in FTP, you can't use path that contain spaces. Filename may * contain spaces. Note 5: in HTTP, the applet use the current Java * parameter to connect to the host. By default, this configuration is to use * the navigator configuration. So, if a proxy is configured in the navigator * network configuration, the applet should use it automatically.
    * Note 3: FTP URL should looks like: * ftp://username:password@myhost.com:21/directory
    * Note 4: in FTP, you'll have to add the jakarta-commons-oro.jar and * jakarta-commons-net.jar jar files in the applet ARCHIVE tag attribute. See * the 'advanced_js_demo.html page for a sample. You'll have to put the two * files coming from the JUpload distribution in the same directory as the * wjhk.jupload.jar.
    * Note 5: in FTP, you can use the user default folder by putting no * folder. The URL can be: ftp://user:mdp@host
    readCookieFromNavigatorSince 4.3.0: Boolean
    * (true)
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    * Since v2.8.1
    If true (default), the applet read cookies from the navigator, with the * javascript document.cookie value. If false, the caller should put the * relevant 'Cookie' header in the specificHeaders applet parameter. This allows * to override any javascript cookie access restriction.
    readUserAgentFromNavigatorSince 4.6.1rc2: Boolean
    * (true)
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    *
    If true (default), the applet read the userAgent from the navigator, with * the javascript document.userAgent value. If false, the caller can put the * relevant userAgent header in the specificHeaders applet parameter.
    realMaxPicHeightSince 3.3.0: Integer.MAX_VALUE
    * (was -1)
    *
    * {@link wjhk.jupload2.policies.PictureUploadPolicy}
    * Since v2.8.1
    This parameters is about the same as maxPicHeight. It overrides it for * pictures that must be transformed (currentlty only when the picture is * rotated).
    * The aim of this parameter, is to prevent the applet to resize picture, and * let the server do it: it will be much quicker.
    * This allows you to: *
      *
    • Put a 'big' maxPicHeight (or don't provide the parameter in the * APPLET tag), and let the server resize the picture according to the real * maxPicHeight. The maxPicHeight will be used when the picture is not * tranformed by the user. *
    • Put this realMaxHeight to the real configured maxPicHeight. The applet * will then directly produce the final file, when it has to tranform the * picture (picture rotation, for instance). *
    *
    * See also maxPicHeight, realMaxPicWidth, maxChunkSize (to override any * server upload size limitation).
    realMaxPicWidthSince 3.3.0: Integer.MAX_VALUE
    * (was -1)
    *
    * {@link wjhk.jupload2.policies.PictureUploadPolicy}
    * Since v2.8.1
    Same as realMaxPicHeight, but for the maximum width of uploaded picture * that must be transformed.
    * See also maxPicWidth, realMaxPicHeight
    retryMaxNumberOf1
    * Since 5.0.0
    Maximum number of retries, that the applet will do, for upload resumable * error. A 'upload resumable error', is typically a network error. The default * value is 0, to maintain the same behaviour as before.
    * This maximum of allowed retries is for each packet, that is: if one packet * fails two times, and succeed in the third attempt, the next packet will still * have up to retryMaxNumberOf retries. For instance, the default value (1), * means that the applet will do a one new attempt after a first upload error, * for each packet.
    retryNbSecondsBetween30
    * Since 5.0.0
    The number of seconds, to wait, before trying a new upload of a packet * whose upload was in error. This is used if retryMaxNumberOf is 1 or * more, and if 'resumable upload error' occurs.
    serverProtocolnull since 2.9.2rc4
    * (before: "HTTP/1.1")
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter allows the control of the protocol toward the server. It * can be HTTP/0.9 (not tested), HTTP/1.0, HTTP/1.1 and FTP. HTTP supports * https. Since version 2.9.2rc4, the default is null, introducing a new * facility of automatically adjusting the protocol according to the server * response.
    * This parameter is really useful only in * {@link wjhk.jupload2.policies.CoppermineUploadPolicy}, as the coppermine * application also controls that the requests send within an HTTP session uses * the same HTTP protocol (as a protection to limit the 'steal' of session * cookies).
    sendMD5Sumfalse
    * since 5.0.0
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter indicates whether the applet will send the MD5Sum for * uploaded files, or not. If set to true, the MD5Sum is sent in the * md5sum HTTP POST argument.
    showLogWindow
    * Since 3.0.2
    * Changed in 3.5.0
    true
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter was formerly known as showStatusBar which now has a * different purpose.
    * Since 3.5.0: Available values are (case sensitive): *
  • true: always visible. *
  • false: always hiden. *
  • onError: the log window is hidden. It will be displayed when an error * occurs. If you put 99 into the debugLevel, then the full debugOutput become * visible if and only if an error occurs

  • * Until 3.4.2, it works this way: If given with the False value, * the log window will be hidden. The applet will still store all debug * information in it. But the user won't see it any more. If a problem occurs, * the urlToSendErrorTo can still be used to log all available * information.
    showStatusBarTrue
    *
    * New meaning since 3.0.2
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This parameter controls if the status bar is shown in the applet. If * shown, the stausbar provides information about the current transfer speed and * estimated time of completion. Before version 3.0.2, this parameter was used * to control visibility of the log window. This is now controlled by * showLogWindow.
    specificHeadersnull
    *
    * Since 3.0.2
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    Allows the caller to add any header(s) to the applet. These headers will * be sent with each HTTP request to the server. If you put several lines in * this parameter, these parameter should be separated by the "\n" string * (not the LineFeed character, but the antislash character followed by the n * character, like msg="\\n";). No "\n" at the end: it will be added * by the applet. In PHP, put '\n', and not "\n" (See PHP doc, on * strings)
    * This allows an easy management of Basic HTTP authentication. Just add * a header like this one:
    * Authorization: Basic Base64EncodedString Where Base64EncodedString is the * string "login:passord" encoded in Base 64.
    sslVerifyCert
    * Since 3.0.2b1
    none
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    With this parameter, the handling of certificates when using SSL can be * configured. There are 4 possible settings:
    *
      *
    • none (default): Any server cert is accepted, no cert-based client * authentication is performed.
    • *
    • server: The server cert is verified against the local truststore * and if that fails, a dialog pops up which asks the user if the certificate * shall be accepted permanently, just for the current session or not at all * (Just like any browser would do).
    • *
    • client: A user-certificate (which must be available in the local * keystore) is used to perform client authentication.
    • *
    • strict: The combination of client and server.
    • *
    *

    * The location of the local truststore and keystore uses the normal JRE * conventions. This means, that the system truststore is used for verifying * server certs (usually in $JAVA_HOME/lib/security/cacerts) unless either the * system property javax.net.ssl.trusStore specifies another location or * a file .truststore exists in the user's home directory. If the user * decides to permanently accept an untrusted certificate, the file * .truststore in the user's home directory is written. The default * keystore (for client certificates) is the file .keystore in the user's * home directory. This can be overridden by setting the system property * javax.net.ssl.keyStore. If the name of the keystore ends in * .p12, it is assumed that the keystore is in PKCS12 format, * otherwise the default format as specified in the JRE security-configuration * is used. *

    * Important Note about client authentication: *

    * At the time of this writing, a serious bug exists in apache 2.0.x * which prevents POST requests when SSL renegotiation is about to happen. * Renegotiation is triggered by a location-based (or directory-based) change of * the SSLVerifyClient directive in apache. Therefore you can not protect * a sub-area of an otherwise unprotected SSL server. You can circumvent that by * setting up a virtualhost which is configured to perform SSL client * verification for the complete virtualhost. Attached to the bug report * at ASF * Bugzilla, there are several patches which claim to fix the problem. * However in that same report, other users complain about those patches to be * ineffective. Therefore, the author recommends avoiding re-negotiation * alltogether by using the virtualhost aproach described above. It is the * understanding of the author, that this bug has been fixed for apache 2.2, * however the author did not verify that. Test-Reports from users running * apache 2.2 are welcome. *

    storeBufferedImagefalse
    * Deprecated
    * {@link wjhk.jupload2.policies.PictureUploadPolicy}
    This parameter indicates that the preview image on the applet is kept in * memory. It works really nice under eclise. But, once in the navigator, the * applet runs very quickly out of memory. So I add a lot of calls to * {@link wjhk.jupload2.filedata.PictureFileData#freeMemory(String, UploadPolicy)} * , but it doesn't change anything. Be careful to this parameter, and let it to * the default value, unless you've well tested it under all your target client * configurations.
    * This parameter will probably never be correctly implemented.
    stringUploadErrorSince 3.2.0: "^ERROR: (.*)$" for all upload policies
    * Empty string ("") [if using DefaultUploadPolicy]
    * "ERROR: (.*)" [if using CopperminUploadPolicy]
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    * Since 2.9.2rc4
    This string is a regular expression. It allows the applet to test that * the server has detected an error in the upload. If this parameter is given to * the applet, the upload thread will try to match this regular expression * against each line of the server response body. If a group is found, it * is considered as the error message, and will be displayed to the user.
    * If the match is successfull once, the upload is considered to have failed. * and {@link wjhk.jupload2.exception.JUploadExceptionUploadFailed} is thrown. * If the expression contains a hunt-group, the matching contents of that group * is reported to the user. For example: If let the default value "^ERROR: * (.*)$" here, the applet will find an error if at least one line returned in * the server response begins with "ERROR: ". Then, all characters that follow * are extracted as the error message. So, if the server response contains the * line "ERROR: md5sum check failed", the string "md5sum check failed" is used * for the exception message. But if it returns a line "maybe ERROR: is it an * error?", then the applet won't find any error in the server response.
    * Note: you can put line breaks in the error message. The message must * be in one line in the HTTP response. To display a line break to the user, * just put the two characters \n in the http response (would be a "\\n" in java * or PHP).
    stringUploadSuccess"^SUCCESS$"
    * empty string ("") since 2.9.0
    * (was ".* 200 OK$" before)
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    This string is a regular expression. It allows the applet to test that * the server has accepted the upload. If this parameter is given to the applet, * the upload thread will try to match this regular expression against each * lines returned from the server.
    * If the match is successfull once, the upload is considered to be a success. * If not, a {@link wjhk.jupload2.exception.JUploadExceptionUploadFailed} is * thrown.
    * The default test expression testes that the web server returns no HTTP error: * 200 is the return code for a successfull HTTP request. It actually means that * postURL is a valid URL, and that the applet was able to send a request to * this URL: there should be no problem with the network configuration, like * proxy, password proxy...).
    * But it doesn't mean that the uploaded files have correctly be managed * by the server. For instance, the URL can be http://sourceforge.net, which, of * course, would not take your files into account.
    * So, as soon as you know a regular expression that test the return from the * target application (and not just a techical HTTP response code), change the * stringUploadSuccess to this value. For instance, the default value will be * matched if the HTTP body content of the server response contains one line * that is exactly 'SUCCESS', without any other character. This 'success' means * that the pictures have correctly uploaded to the server, and that he * successfully managed the uploaded files.
    stringUploadWarning"^WARNING: (.*)$"
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    * Since 3.4.2
    This string is a regular expression. It allows the applet to test that * the server has detected a warning was generated by the server. This warning * is just a warning, that will be displayed to the user, as is. There may be * several warnings in the server return. If one or more warning is/are * received, the message(s) will be displayed to the user.
    * If the expression contains a hunt-group, the matching contents of that group * is reported to the user. For example: If you let the default value "^WARNING: * (.*)$" here, the applet will find an error if at least one line returned in * the server response begins with "WARNING: ". Then, all characters that follow * are extracted as the error message. So, if the server response contains the * line "WARNING: Bad encoding", the string "Bad encoding" is displayed as * warning message to the user. But if it returns a line "maybe WARNING: is it * an error?", then the applet won't find any warning in the server response.
    * Notes: *
  • There is no link between these warning and the fact the upload is * considered to be a success or not. Upload success is only based on the * success and error string. See the stringUploadSuccess and * stringUploadError applet parameters, here above. *
  • You can put line breaks in the error message. The message must be in one * line in the HTTP response. To display a line break to the user, just put the * two characters \n in the http response (would be a "\\n" in java or PHP). *
  • targetPictureFormatEmpty String
    * {@link wjhk.jupload2.policies.PictureUploadPolicy}
    This parameter can contain a list to convert image formats *

    * Example 1:{@code "png,bmp:jpg;gif:png;"} *

      *
    • both png and bmp files will be converted to jpg,
    • *
    • gif files will be converted to png
    • *
    * Example 2:{@code "jpeg,jpg:png;"} *
      *
    • both jpeg and jpg files will be converted to png,
    • *
    *

    * the value is expected to be a semi-colon separated list of relations from * source-format(s) to a target format.
    * format: {SOURCEFORMAT{,SOURCEFORMAT*}:TARGETFORMAT;}* *
      *
    • formats can contain any picture writer known by the JVM. For instance: * jpeg, png, gif. All standard formats should be available. More information * can be found on the java.sun.com web site. *
    • SOURCEFORMAT: the source format that should be converted to the * TARGETFORMAT
      * e.g. png, jpg, jpeg, ..
    • *
    • TARGETFORMAT: the target format that all given SOURCEFORMAT should be * converted to
      * e.g. png, jpg, jpeg, ..
    • *
    • all format strings are case insensitive, so all following strings are the * same: *
        *
      • "jpeg,jpg:png;"
      • *
      • "JPEG,JPG:PNG;"
      • *
      • "jPeG,JpG:pNg;"
      • *
      *
    • *
    * notes: *
      *
    • animated gifs will not be converted
    • *
    • jpg and jpeg are distinct types.
    • *
    • gifs can only be converted if the user has installed JRE >= 1.6
    • *
    • the trailing semi-colon is optional
    • *
    • when a file needs to be transformed, the content type will reflect the * new picture format. the file extension will be changed dependant on the * parameter keepOriginalFileExtensionForConvertedImages *
        *
      • example1: *
          *
        • targetPictureFormat="bmp:png;"
        • *
        • keepOriginalFileExtensionForConvertedImages=false (default)
        • *
        * When you upload: C:\myBitmap.bmp, the filename will be changed * to C:\myBitmap.png and transferred to the server, and the * content-type will be changed to "image/png"
      • *
      • *
      • example2: *
          *
        • targetPictureFormat="bmp:png;"
        • *
        • keepOriginalFileExtensionForConvertedImages=true
        • *
        * When you upload: C:\myBitmap.bmp, the filename will NOT be * changed and transferred to the server, but the content-type will be changed * to "image/png"
      • *
      *
    • *
    * see {@link wjhk.jupload2.filedata.helper.ImageFileConversionInfo}
    * see keepOriginalFileExtensionForConvertedImages
    uploadPolicyDefaultUploadPolicy
    *
    * see {@link wjhk.jupload2.policies.UploadPolicyFactory}
    This parameter contains the class name for the UploadPolicy that should * be used. If it is not set, or if its value is unknown from * {@link wjhk.jupload2.policies.UploadPolicyFactory#getUploadPolicy(JUploadContext)} * , the {@link wjhk.jupload2.policies.DefaultUploadPolicy} is used.
    urlToSendErrorTonull
    *
    * {@link wjhk.jupload2.policies.DefaultUploadPolicy}
    If this url is given, and an upload error occurs, the applet posts all * debug output to this address. It's up to this URL to handle this message. It * is possible to just store the file, or to log the error in a database, or to * send a mail (like the mail.php script given with the coppermine pack).
    * Notes: *
  • Only http and https URL schemes are supported.
  • *
  • The error information is sent in a POST request sent to the given URL. * These post parameters are used: description (a quick description of the * error), javaError (the java output for the error, or null if no java error * were caught) and debugOutput (the full debug generated by the applet).
  • *
    *

    HTML call example

    *

    * Below, an example of how to put the applet into a PHP page is shown: *

    *
     *                                     <applet name="JUpload" code="wjhk.jupload2.JUploadApplet"
     *                                       archive="plugins/jupload/wjhk.jupload.jar"
     *                                       <!-- Applet display size, on the navigator page -->
     *                                       width="500" height="700"
     *                                       <!-- The applet uses some javascript functions, so we must allow that : -->
     *                                       mayscript="true">
     *                                       <!-- No parameter is mandatory. We don't precise the UploadPolicy, so
     *                                            DefaultUploadPolicy is used. The applet behaves like the original
     *                                            JUpload. (jupload v1) -->
     *                                       <param name="postURL" value="http://some.host.com/youruploadpage.php">
     *                                       Java 1.5 or higher plugin required.
     *                                     </applet>
     * 
    *
    * * * @author etienne_sf * @version $Revision: 1388 $ * @see wjhk.jupload2.policies.DefaultUploadPolicy */ public interface UploadPolicy { /* * Available parameters for the applet. New parameters (for instance for new * policies) should all be added here, in alphabetic order. This ensures * that all tags are unique */ /*************************************************************************** * ************************************************************************ * ************************* LIST OF PROPERTIES ************************** * ************************************************************************ **************************************************************************/ /** * Parameter/Property name for URL to be loaded after an successful upload. */ public final static String PROP_AFTER_UPLOAD_URL = "afterUploadURL"; /** * Parameter/Property name for allowing persistent HTTP connections. */ public final static String PROP_ALLOW_HTTP_PERSISTENT = "allowHttpPersistent"; /** * Parameter/Property name for specifying the allowed file extensions */ public final static String PROP_ALLOWED_FILE_EXTENSIONS = "allowedFileExtensions"; /** * Parameter/Property name for specifying the album id */ public final static String PROP_ALBUM_ID = "albumId"; /** * Indicates the directory, from which the applet should open the browsing * window (file chooser) first. */ public final static String PROP_BROWSING_DIRECTORY = "browsingDirectory"; /** * Parameter/Property name for specifying if images should be cached in * memory. Be careful: if set to true, you'll probably have memory problems * while in a navigator. */ public final static String PROP_STORE_BUFFERED_IMAGE = "storeBufferedImage"; /** * Parameter/Property name for specifying the debug level */ public final static String PROP_DEBUG_LEVEL = "debugLevel"; /** * This parameter allows to control whether the file icons in the file * chooser are calculated from the file content. This is currently only * available for pictures.
    * If activated, the file chooser will open each pictures, and calculate the * icon by resizing the picture. This is done in by using thread of minimam * priority, to minimize performances impact on the navigator. Available * values are:
  • -1: disabled. The default system are used.
  • 0 * (default): available only in picture mode. That is: the current upload * policy is an instance of or a class inheriting from * {@link PictureUploadPolicy}
  • 1: available for all upload policies. *
  • */ public final static String PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT = "fileChooserIconFromFileContent"; /** * This parameter allows to control the size of icons, in pixels, in the * file chooser. Used only when fileChooserIconFromFileContent is activated. */ public final static String PROP_FILE_CHOOSER_ICON_SIZE = "fileChooserIconSize"; /** * Allows control on the preview on the file chooser. Only for * {@link PictureUploadPolicy} and its inheritants. */ public final static String PROP_FILE_CHOOSER_IMAGE_PREVIEW = "fileChooserImagePreview"; /** * Contains the name of the file filter, as it will be displayed in the drop * down list of filters, in the file chooser. If this name is given to the * applet, it will be returned by the {@link FileFilter#getDescription()} * method. */ public final static String PROP_FILE_FILTER_NAME = "fileFilterName"; /** * Parameter/Property name for specifying the encoding of file names. */ public final static String PROP_FILENAME_ENCODING = "filenameEncoding"; /** * Parameter/Property name for specifying additional form data. */ public final static String PROP_FORMDATA = "formdata"; /** * Parameter/Property name to specify, when in FTP mode, if subfolders must * be created, or if all files must be uploaded on the root of postURL. */ public final static String PROP_FTP_CREATE_DIRECTORY_STRUCTURE = "ftpCreateDirectoryStructure"; /** FTP: binary or ascii mode */ public final static String PROP_FTP_TRANSFERT_BINARY = "ftpTransfertBinary"; /** FTP: passive or active mode */ public final static String PROP_FTP_TRANSFERT_PASSIVE = "ftpTransfertPassive"; /** * Parameter/Property name for specifying high quality previews. */ public final static String PROP_HIGH_QUALITY_PREVIEW = "highQualityPreview"; /** * Parameter/Property name for specifying high quality previews. */ public final static String PROP_HTTP_UPLOAD_PARAMETER_NAME = "httpUploadParameterName"; /** * Parameter/Property name for specifying high quality previews. */ public final static String PROP_HTTP_UPLOAD_PARAMETER_TYPE = "httpUploadParameterType"; /** * Parameter/Property name for specifying the UI language */ public final static String PROP_LANG = "lang"; /** * Parameter/Property name for specifying a list of specific headers, that * will be added to all HTTP request to the server. The parameter can be * used for Basic Authentication, by adding this header: Authorization: * Basic [Bae64 encoding of the string "user:password"] */ public final static String PROP_SPECIFIC_HEADERS = "specificHeaders"; /** * Parameter/Property name for specifying a PLAF class to load. */ public final static String PROP_LOOK_AND_FEEL = "lookAndFeel"; /** * Parameter/Property name for specifying the maximum size of a chunk of * uploaded data. */ public final static String PROP_MAX_CHUNK_SIZE = "maxChunkSize"; /** * Parameter/Property name for specifying the maximum size of a single file. */ public final static String PROP_MAX_FILE_SIZE = "maxFileSize"; /** * Parameter/Property name for specifying the maximum height of a picture. */ public final static String PROP_MAX_HEIGHT = "maxPicHeight"; /** * Parameter/Property name for specifying the maximum width of a picture. */ public final static String PROP_MAX_WIDTH = "maxPicWidth"; /** * Parameter/Property name for specifying the maximum number of file to be * uploaded in a single request. */ public final static String PROP_NB_FILES_PER_REQUEST = "nbFilesPerRequest"; /** * Parameter/Property name for specifying compression of the written picture * file, if any. */ public final static String PROP_PICTURE_COMPRESSION_QUALITY = "pictureCompressionQuality"; /** * Parameter/Property name for specifying whether picture metadata (EXIF * coming from the camera for instance. */ public final static String PROP_PICTURE_TRANSMIT_METADATA = "pictureTransmitMetadata"; /** * Parameter/Property name for specifying URL of the upload post request. */ public final static String PROP_POST_URL = "postURL"; /** * Parameter/Property name for specifying URL of the upload post request. */ public final static String PROP_AFTER_UPLOAD_TARGET = "afterUploadTarget"; /** * Read cookies from javascript command: document.cookie (or not) */ public final static String PROP_READ_COOKIE_FROM_NAVIGATOR = "readCookieFromNavigator"; /** * Read userAgent from javascript command: document.userAgent (or not) */ public final static String PROP_READ_USER_AGENT_FROM_NAVIGATOR = "readUserAgentFromNavigator"; /** * Parameter/Property name for specifying the real (server-side-desired) * picture height. */ public final static String PROP_REAL_MAX_HEIGHT = "realMaxPicHeight"; /** * Parameter/Property name for specifying the real (server-side-desired) * picture width. */ public final static String PROP_REAL_MAX_WIDTH = "realMaxPicWidth"; /** * Maximum number of retries, that the applet will do, for upload resumable * error. A 'upload resumable error', is typically a network error. The * default value is 0, to maintain the same behaviour as before. */ public final static String PROP_RETRY_MAX_NUMBER_OF = "retryMaxNumberOf"; /** * The number of seconds, to wait, before trying a new upload. This is used * if retryMaxNumberOf is 1 or more, and if 'resumable upload error' * occurs. */ public final static String PROP_RETRY_NB_SECONDS_BETWEEN = "retryNbSecondsBetween"; /** * Parameter/Property name for specifying the server protocol version. */ public final static String PROP_SERVER_PROTOCOL = "serverProtocol"; /** * Parameter/Property name to spceify whether the md5sum for uploaded file * should be sent. */ public final static String PROP_SEND_MD5_SUM = "sendMD5Sum"; /** * Parameter/Property name for specifying if the log window should be * visible. */ public final static String PROP_SHOW_LOGWINDOW = "showLogWindow"; /** * Parameter/Property name for specifying if the status bar should be * visible. */ public final static String PROP_SHOW_STATUSBAR = "showStatusbar"; /** * Parameter/Property name for specifying how certificates are handled when * uploading via SSL. */ public final static String PROP_SSL_VERIFY_CERT = "sslVerifyCert"; /** * Parameter/Property name for specifying if the pattern that indicates an * error in the server's response-body. */ public final static String PROP_STRING_UPLOAD_ERROR = "stringUploadError"; /** * Parameter/Property name for specifying if the pattern that indicates * success in the server's response-body. */ public final static String PROP_STRING_UPLOAD_SUCCESS = "stringUploadSuccess"; /** * Parameter/Property name for specifying if the pattern that indicates a * warning in the server's response-body. */ public final static String PROP_STRING_UPLOAD_WARNING = "stringUploadWarning"; /** * Parameter/Property name for specifying the target picture format * conversions */ public final static String PROP_TARGET_PICTURE_FORMAT = "targetPictureFormat"; /** * Parameter/Property name for specifying if the original file extension * should be changed if an image is converted to another format */ public final static String PROP_KEEP_ORIG_EXTENSION = "keepOriginalFileExtensionForConvertedImages"; /** * Parameter/Property name for specifying the upload policy class. */ public final static String PROP_UPLOAD_POLICY = "uploadPolicy"; /** * Parameter/Property name for specifying the URL for delivering error * reports. */ public final static String PROP_URL_TO_SEND_ERROR_TO = "urlToSendErrorTo"; /*************************************************************************** * ************************************************************************ * ************************* LIST OF ALLOWED VALUES ********************* * ************************************************************************ **************************************************************************/ /** * Indicates that, in the HTTP upload request, the parameter that containts * the uploaded files is an Iteration. For instance: from File0 to FileN * (for N+1 files). */ public final String HTTPUPLOADPARAMETERTYPE_ARRAY = "array"; /** * Indicates that, in the HTTP upload request, the parameter that containts * the uploaded files is an Iteration. For instance: from File0 to FileN * (for N+1 files). */ public final String HTTPUPLOADPARAMETERTYPE_ITERATION = "iteration"; /** * Indicates that, in the HTTP upload request, there will be only one file. * This value is only valid when nbFilesPerRequest is 1. The parameters in * the HTTP upload request are let untransformed. For instance, if * httpUploadParameterName is the default value (File), the file content * will be loaded under the HTTP parameter 'File'. */ public final String HTTPUPLOADPARAMETERTYPE_ONE_FILE = "oneFile"; /** Indicates that the log window is always visible. */ public final String SHOWLOGWINDOW_TRUE = "true"; /** Indicates that the log window is always hidden. */ public final String SHOWLOGWINDOW_FALSE = "false"; /** * Indicates that the log window is hidden, and will become visible only * when an error occurs. */ public final String SHOWLOGWINDOW_ONERROR = "onError"; /*************************************************************************** * ************************************************************************ * ************************* LIST OF DEFAULT VALUES ********************** * ************************************************************************ **************************************************************************/ /** * Default value for parameter "afterUploadTarget". */ public final static String DEFAULT_AFTER_UPLOAD_TARGET = null; /** * Default value for parameter "afterUploadURL" */ public final static String DEFAULT_AFTER_UPLOAD_URL = null; /** * Default value for parameter "allowHttpPersisten". */ public final static boolean DEFAULT_ALLOW_HTTP_PERSISTENT = false; /** * Default value for parameter "allowedFileExtensions". */ public final static String DEFAULT_ALLOWED_FILE_EXTENSIONS = null; /** * Default value for parameter "albumId". */ public final static int DEFAULT_ALBUM_ID = 0; /** * Default value for parameter "storeBufferedImage". Be careful: if set to * true, you'll probably have memory problems while in a navigator. */ public final static boolean DEFAULT_STORE_BUFFERED_IMAGE = false; /** * Default value for the browsing window first: no specific directory. */ public final static String DEFAULT_BROWSING_DIRECTORY = null; /** * Default value for date format when changing date/time variable to String. */ public final static String DEFAULT_DATE_FORMAT = "dd/MM/yyyy HH:mm:ss"; /** * Default value for parameter "debugLevel". */ public final static int DEFAULT_DEBUG_LEVEL = 0; /** * Default value for applet parameter "fileChooserIconFromFileContent". * * @see #PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT */ public final static int DEFAULT_FILE_CHOOSER_ICON_FROM_FILE_CONTENT = 0; /** * Default value for applet parameter "fileChooserIconSize". * * @see #PROP_FILE_CHOOSER_ICON_SIZE */ public final static int DEFAULT_FILE_CHOOSER_ICON_SIZE = 20; /** * Default value for applet parameter "fileChooserImagePreview". * * @see #PROP_FILE_CHOOSER_IMAGE_PREVIEW */ public final static boolean DEFAULT_FILE_CHOOSER_IMAGE_PREVIEW = true; /** * Default value for applet parameter "fileFilterName". This default value * let the {@link DefaultUploadPolicy} return a calculated name, which * contains the list of allowed file extensions. * * @see #PROP_FILE_FILTER_NAME * @see #PROP_ALLOWED_FILE_EXTENSIONS */ public final static String DEFAULT_FILE_FILTER_NAME = null; /** * Default value for applet parameter "ftpCreateDirectoryStructure". * * @see #PROP_FTP_CREATE_DIRECTORY_STRUCTURE */ public final static boolean DEFAULT_FTP_CREATE_DIRECTORY_STRUCTURE = false; /** FTP: binary or ascii mode */ public final static boolean DEFAULT_FTP_TRANSFERT_BINARY = true; /** FTP: passive or active mode */ public final static boolean DEFAULT_FTP_TRANSFERT_PASSIVE = true; /** Default value for parameter "lang". */ public final static String DEFAULT_LANG = null; /** * Default value for parameter "filenameEncoding". Note: the * CoppermineUploadPolicy forces it to "UTF8". */ public final static String DEFAULT_FILENAME_ENCODING = null; /** Default value for parameter "highQualityPreview". */ public final static boolean DEFAULT_HIGH_QUALITY_PREVIEW = false; /** Default value for parameter "httpUploadParameterName". */ public final static String DEFAULT_HTTP_UPLOAD_PARAMETER_NAME = "File"; /** Default value for parameter "httpUploadParameterName". */ public final static String DEFAULT_HTTP_UPLOAD_PARAMETER_TYPE = HTTPUPLOADPARAMETERTYPE_ITERATION; /** Default value for parameter "lookAndFeel". */ public final static String DEFAULT_LOOK_AND_FEEL = ""; /** Default value for parameter "maxChunkSize". */ public final static long DEFAULT_MAX_CHUNK_SIZE = Long.MAX_VALUE; /** * Default value for parameter "maxFileSize". Take care of this parameter if * chunk upload is activated! See comment above. */ public final static long DEFAULT_MAX_FILE_SIZE = Long.MAX_VALUE; /** Default value for parameter "maxPicWidth". */ public final static int DEFAULT_MAX_WIDTH = Integer.MAX_VALUE; /** Default value for parameter "maxPicHeight". */ public final static int DEFAULT_MAX_HEIGHT = Integer.MAX_VALUE; /** * Default value for parameter "maxPicHeight". Note: the * CoppermineUploadPolicy forces it to 1. */ public final static int DEFAULT_NB_FILES_PER_REQUEST = 1; /** * Default value for parameter "pictureCompressionQuality". */ public final static float DEFAULT_PICTURE_COMPRESSION_QUALITY = (float) 0.8; /** * Default value for parameter "pictureCompressionQuality". */ public final static boolean DEFAULT_PICTURE_TRANSMIT_METADATA = false; /** * Default value for parameter "postURL". */ public final static String DEFAULT_POST_URL = null; /** * Default value for parameter "readCookieFromNavigator". */ public final static boolean DEFAULT_READ_COOKIE_FROM_NAVIGATOR = true; /** * Default value for parameter "readUserAgentFromNavigator". */ public final static boolean DEFAULT_READ_USER_AGENT_FROM_NAVIGATOR = true; /** * Default value for parameter "realMaxPicWidth". */ public final static int DEFAULT_REAL_MAX_WIDTH = Integer.MAX_VALUE; /** * Default value for parameter "realMaxPicHeight". */ public final static int DEFAULT_REAL_MAX_HEIGHT = Integer.MAX_VALUE; /** * Default value for parameter "retryMaxNumberOf". */ public final static int DEFAULT_RETRY_MAX_NUMBER_OF = 1; /** * Default value for parameter "retryNbSecondsBetween". */ public final static int DEFAULT_RETRY_NB_SECONDS_BETWEEN = 30; /** * Default value for parameter "serverProtocol". */ public final static String DEFAULT_SERVER_PROTOCOL = "HTTP/1.1"; /** * Default value for the sendMD5Sum applet parameter */ public final static boolean DEFAULT_SEND_MD5_SUM = false; /** * Default value for parameter "showLogWindow". */ public final static String DEFAULT_SHOW_LOGWINDOW = "true"; /** * Default value for parameter "showStatusBar". */ public final static boolean DEFAULT_SHOW_STATUSBAR = true; /** * Default value for parameter "sslVerifyCert" */ public final static String DEFAULT_SPECIFIC_HEADERS = null; /** * Default value for parameter "sslVerifyCert" */ public final static String DEFAULT_SSL_VERIFY_CERT = "none"; /** * Default value for parameter "stringUploadError". * * @since 2.9.2rc4 */ public final static String DEFAULT_STRING_UPLOAD_ERROR = "^ERROR: (.*)$"; /** * Default value for parameter "stringUploadSuccess". Note: was ".* 200 OK$" * before 2.9.0 */ public final static String DEFAULT_STRING_UPLOAD_SUCCESS = "^SUCCESS$"; /** * Default value for parameter "stringUploadWarning". */ public final static String DEFAULT_STRING_UPLOAD_WARNING = "^WARNING: (.*)$"; /** * Default value for parameter "targetPictureFormat". */ public final static String DEFAULT_TARGET_PICTURE_FORMAT = null; /** * default value for parameter "keepOriginalFileExtensionForConvertedImages" */ public final static boolean DEFAULT_KEEP_ORIG_EXTENSION = false; /** * Default value for parameter "uploadPolicy". */ public final static String DEFAULT_UPLOAD_POLICY = "DefaultUploadPolicy"; /** * Default value for parameter "urlToSendErrorTo". */ public final static String DEFAULT_URL_TO_SEND_ERROR_TO = null; /** * Default value for parameter "formdata" * * @since 2.9.2rc4 */ public final static String DEFAULT_FORMDATA = null; /***************************************************************************/ /******************** MISC CONSTANTS ***************************************/ /***************************************************************************/ /** * Indicating that the applet is currently waiting for the user, to select * files or start an uploading. */ public final static int EXEC_STATUS_READY = 1; /** Indicating that the applet is currently uploading files */ public final static int EXEC_STATUS_UPLOADING = 2; /*************************************************************************** * ************************************************************************* * ********************* LIST OF METHODS ********************************** * ************************************************************************* **************************************************************************/ /** * This method allows the upolad policy to override the content of the * applet part that is above the file list, called here the 'top panel'. * That is: the part that contains the Browse, Remove and RemoveAll buttons. * The default implementation is defined in * {@link wjhk.jupload2.policies.DefaultUploadPolicy#createTopPanel(JButton, JButton, JButton, JUploadPanel)} * .
    * You can see an example in the * {@link PictureUploadPolicy#createTopPanel(JButton, JButton, JButton, JUploadPanel)} * upload policy implementation.
    * Note: This method is called by the * {@link DefaultUploadPolicy#addComponentsToJUploadPanel(JUploadPanel)} * method. If you create an upload policy that overrides the * addComponentsToJUploadPanel method, it's up to you to call it. * * @param browse * The default browse button. * @param remove * The default removeSelected button. * @param removeAll * The default removeAll button. * @param mainPanel * The panel that contains all objects. * @return the topPanel, that will be displayed on the top of the Applet. */ public JPanel createTopPanel(JButton browse, JButton remove, JButton removeAll, JUploadPanel mainPanel); /** * This method is called to create the progress panel. The default * implementation is defined in * {@link wjhk.jupload2.policies.DefaultUploadPolicy#createProgressPanel(JProgressBar, JProgressBar, JButton, JButton, JUploadPanel)} * . * * @param preparationProgressBar * The default preparation progress bar. * @param uploadProgressBar * The default upload progress bar. * @param uploadButton * The default upload button. * @param stopButton * The default stop button. * @param mainPanel * The panel that contains all objects. * @return the topPanel, that will be displayed on the top of the Applet. */ public JPanel createProgressPanel(JProgressBar preparationProgressBar, JProgressBar uploadProgressBar, JButton uploadButton, JButton stopButton, JUploadPanel mainPanel); /** * This method is used to create a new status bar. The default * implementation is defined in * {@link wjhk.jupload2.policies.DefaultUploadPolicy#createStatusBar(JLabel, JUploadPanel)} * . * * @param statusContent * The status bar content * @param mainPanel * The panel that contains all objects. * @return the topPanel, that will be displayed on the top of the Applet. */ public JPanel createStatusBar(JLabel statusContent, JUploadPanel mainPanel); /** * This methods allow the upload policy to override the default disposition * of the components on the applet.
    * There are some utility methods to style file panel elements (font/color), see * {@link wjhk.jupload2.gui.filepanel.FilePanel}. * @param jUploadPanel * The main applet panel. * @see #createTopPanel(JButton, JButton, JButton, JUploadPanel) */ public void addComponentsToJUploadPanel(JUploadPanel jUploadPanel); /** * This methods creates a new FileData instance (or one of its inherited * classes), and return it to the caller. * * @param file * The file used to create the FileData instance. This method is * called once for each file selected by the user, even if the * user added several files in one 'shot'. * @param root * An optional toplevel directory of a hierarchy (can be null). * @return A FileData instance. The exact class depends on the * currentUploadPolicy. Can be null, if the policy performs checks, * and the given file is not Ok for these controls. See * {@link PictureUploadPolicy#createFileData(File,File)} for an * example. It's up to the upload policy to display a message to * inform the user that this file won't be added to the file list. * @throws JUploadExceptionStopAddingFiles * The exception is not really an error. It allows an easy way * to indicates that the applet should stop adding files when * the user clicked on the 'Cancel' button. */ public FileData createFileData(File file, File root) throws JUploadExceptionStopAddingFiles; /** * This method displays the applet parameter list, according to the current * debugLevel. It is called by the {@link #setDebugLevel(int)} method. It * should be override by any subclasses, that should display its own * parameters, then call super.displayParameterStatus(). */ public void displayParameterStatus(); /** * Reaction to the applet start. This method was added from the patch * 3035735 given by Tsukasa Hamano (SF login: cuspy). Its aim is to move all * call to JSObject from the applet.init() method to the applet.start() * method. This prevents a crash, under Safari. */ public void start(); /** * This method is called by the {@link JUploadPanel#updateButtonState()} * method, when the execution status of the applet changes. This allow the * applet to manage specific GUI items, depending on the current execution * status of the applet. * * @param executionStatus * One of the EXEC_STATUS_XXX constant. */ public void updateButtonState(int executionStatus); // ////////////////////////////////////////////////////////////////////////////////////////////// // /////////////////// getters / setters // ////////////////////////////////////////////////////////////////////////////////////////////// /** * This allow runtime modifications of properties. With this method, you can * change any applet parameter after the applet initilization, with * JavaScript for instance. If the applet parameters given in prop is * not managed by this method, a warning is displayed in the log window. * * @param prop * The applet parameter name. * @param value * The new value for this parameter. If the value is not valid * (for instance aaa for a number), a warning is displayed * in the log window, and the existing value is not changed. * @throws JUploadException * @exception JUploadExceptionStopAddingFiles * indicates that the applet should stop strying adding the * current file selection. Useful for instance, when a user * drop a directory, full of unallowed file: it's annoying * for the user to click 'Ok' for each file in the alert box. */ public void setProperty(String prop, String value) throws JUploadException; /** * Retrieves the current value for the afterUploadURL applet parameter. * * @return The current value for he afterUploadURL applet parameter. */ public String getAfterUploadURL(); /** * Retrieves the current value for allowHttpPersistent * * @return Current value for allowHttpPersistent */ public boolean getAllowHttpPersistent(); /** * Retrieves the current value for allowedFileExtensions * * * @return Current value for allowedFileExtensions */ public String getAllowedFileExtensions(); /** * A useful function, that has nothing to do with an upload policy. But it * is useful to have it here, as the uploadPolicy is known everywhere in the * applet. * * @return Reference to the current JUpload context. */ public JUploadContext getContext(); /** * Set the current directory. * * @param currentBrowsingDirectoryParam * The directory that will be the current one, the next time the * file chooser is opened. * @see #getCurrentBrowsingDirectory() * @deprecated */ public void setCurrentBrowsingDirectory(File currentBrowsingDirectoryParam); /** * Set the current directory. * * @param currentBrowsingDirectoryParam * The directory that will be the current one, the next time the * file chooser is opened. This directory may begin with ~/ or ~\ * @see #getCurrentBrowsingDirectory() */ public void setCurrentBrowsingDirectory(String currentBrowsingDirectoryParam); /** * Returns the current browsing directory, that is: the directory that will * be current the next time the file chooser is opened. It is initialized * with the browsingDirectory applet parameter. Then, it contains the last * directory used in the file chooser. * * @return The directory that will be the current one, the next time the * file chooser is opened. */ public File getCurrentBrowsingDirectory(); /** * Returns the currently choosen format for date. It must be compatible with * the SimpleDateFormat standard Java class. * * @return The date format. */ public String getDateFormat(); /** * This method indicate whether or not the debug messages must be displayed. * Default is no debug (0).
    * To activate the debug, add a 'debugLevel' parameter to the applet (with 1 * to n value), or call this method. Currently, level used in the code are * between 0 (no debug) and 100 (max debug).
    * With a 0 value, no debug messages will be displayed. The * {@link DefaultUploadPolicy}.addMsgToDebugBufferString method stores all * debug output in a BufferString. * * @param debugLevel * The new debugLevel. * @see DefaultUploadPolicy#sendDebugInformation(String, Exception) */ public void setDebugLevel(int debugLevel); /** * This method returns the current debug level. * * @return The current debug level * @see #setDebugLevel(int) */ public int getDebugLevel(); /** * Getter for the fileFilterName property. * * @return Stored value for fileFilterName * @see UploadPolicy#PROP_FILE_FILTER_NAME */ public String getFileFilterName(); /** * Getter for the fileChooserIconFromFileContent applet parameter. * * @return Stored value for fileChooserIconFromFileContent * @see #PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT */ public int getFileChooserIconFromFileContent(); /** * Getter for the fileChooserIconSize applet parameter. * * @return Stored value for fileChooserIconSize * @see #PROP_FILE_CHOOSER_ICON_SIZE */ public int getFileChooserIconSize(); /** * Returns the encoding that should be used for the filename. This encoding * has no impact on the content of the file that will be uploaded. * * @return The encoding name, like UTF-8 (see the Charset JDK * documentation). */ public String getFilenameEncoding(); /** * Returns the current value for the ftpCreateDirectoryStructure applet * parameter. * * @return The current value of ftpCreateDirectoryStructure */ public boolean getFtpCreateDirectoryStructure(); /** * Returns the current value for the ftpTransfertBinary applet parameter. * * @return The current value of ftpTransfertBinary */ public boolean getFtpTransfertBinary(); /** * Returns the current value for the ftpTransfertPassive applet parameter. * * @return The current value of ftpTransfertPassive */ public boolean getFtpTransfertPassive(); /** * This method sets the current language to take into account. It loads the * lang resourceBundle, which will allow the applet to display the texts in * the correct language. * * @param lang * The new language to take into account. See the * java.util.Locale(String) constructor for a list of valid * values. */ public void setLang(String lang); /** * Returns the value of the applet parameter maxChunkSize (see above for a * description of all applet parameters) * * @return the current value of maxChunkSize. */ public long getMaxChunkSize(); /** * Returns the value of the applet parameter maxFileSize (see above for a * description of all applet parameters) * * @return the current value of maxFileSize. */ public long getMaxFileSize(); /** * This function returns the number of files should be uploaded during one * access to the server. If negative or 0, all files are to be uploaded in * one HTTP request. If positive, each HTTP upload contains this number of * files. The last upload request may contain less files.
    * Examples : * * * @return Returns the maximum number of files, to download in one HTTP * request. */ public int getNbFilesPerRequest(); /** * Return the current value of readUserAgentFromNavigator * * @return Current value of readUserAgentFromNavigator */ public boolean getReadUserAgentFromNavigator(); /** * Return the current value of retryMaxNumberOf * * @return Current value of retryMaxNumberOf */ public int getRetryMaxNumberOf(); /** * Return the current value of retryNbSecondsBetween * * @return Current value of retryNbSecondsBetween */ public int getRetryNbSecondsBetween(); /** * Return the current value of readCookieFromNavigator * * @return Current value of readCookieFromNavigator */ public boolean getReadCookieFromNavigator(); /** * Get the target URL for upload. * * @return Should be valid URL... */ public String getPostURL(); /** * The URL can change during the life of our policy ... * * @param postURL * @throws JUploadException */ public void setPostURL(String postURL) throws JUploadException; /** * Return the target, specified as applet parameter "afterUploadTarget" * * @return the specified target. */ public String getAfterUploadTarget(); /** * HTTP protocol that should be used to send the HTTP request. Currently, * this is mainly used by * {@link wjhk.jupload2.policies.CoppermineUploadPolicy}, as the coppermine * control that the protocol used for each HTTP request is the same as the * one used during the session creation. It is used in the default policy, * as it could be used elsewhere.
    * Default is : HTTP/1.1 * * @return The selected server protocol. */ public String getServerProtocol(); /** * @param serverProtocol * The protocol is set from the postURL. For HTTP URL, a HEAD * request is done toward the server, to check if any temporary * redirection is occuring. */ public void setServerProtocol(String serverProtocol); /** * MD5Sum allows the server to control that the file has been correctly * uploaded. This is interesting, when uploading in chunk mode. But * calculating this can be long, for big files. * * @return true or false, whether the md5sum should be processed and sent to * the server. */ public boolean getSendMD5Sum(); /** * MD5Sum allows the server to control that the file has been correctly * uploaded. This is interesting, when uploading in chunk mode. But * calculating this can be long, for big files. * * @param sendMD5Sum * true or false, whether the md5sum should be processed and sent * to the server. */ public void setSendMD5Sum(boolean sendMD5Sum); /** * Retrieves SSL verification mode. * * @return The current SSL verification mode. */ public int getSslVerifyCert(); /** * @param showLogWindow * The show window status to set. * @see #getShowLogWindow() */ public void setShowLogWindow(String showLogWindow); /** * Indicate whether the log window should be shown. It may be convenient to * hide it, as it contains mostly debug information. But it still is the * only place where possible errors and warnings are shown.
    * Default is : true * * @return The current value for the showStatusBar applet parameter. */ public String getShowLogWindow(); /** * Returns the list of specific headers, that will be added to all HTTP * request to the server. * * @return List of specific headers, with a \r\n at the end of each header. */ public String getSpecificHeaders(); /** * Get the original name of the file on the disk. This function can encode * the filename (see the filenameEncoding parameter). By default, the * original filename is returned. * * @param fileData * The file data whose upload file name must be calculated. * @param index * index of the file in the current request to the server (from 0 * to n) * @return The filename the is given in the filename part of the * Content-Disposition header. * @throws JUploadException */ public String getUploadFilename(FileData fileData, int index) throws JUploadException; /** * Get an upload filename, that is to be send in the HTTP upload request. * This is the name part of the Content-Disposition header. That is: this is * the name under which you can manage the file (for instance in the * _FILES[$name] in PHP) and not the filename of the original file.
    * If you're using one of the core JUpload {@link UploadPolicy}, the value * for this parameter is controled by the applet parameters: * targetPictureFormat and keepOriginalFileExtensionForConvertedImages. * * @param fileData * The file data whose upload name must be calculated. * @param index * index of the file in the current request to the server (from 0 * to n) * @return The name part of the Content-Disposition header. * @throws JUploadException * @see #getUploadFilename(FileData, int) */ public String getUploadName(FileData fileData, int index) throws JUploadException; /** * Returns the current URL where error log must be posted. See Parameters * * @return the urlToSendErrorTo */ public String getUrlToSendErrorTo(); /** * @param urlToSendErrorTo * the urlToSendErrorTo to set * @throws JUploadException */ public void setUrlToSendErrorTo(String urlToSendErrorTo) throws JUploadException; /** * Retrieve the regular expression that will be tested against each line of * the server answer. If one line matches this expression, that upload is * marked as failed.
    * * @return The regular expression that must be run again each line of the * http answer. */ public String getStringUploadError(); /** * Get the regular expression that will be tested against each line of the * server answer. If one line matches this expression, that upload is marked * as successful.
    * The upload works this way: *
      *
    1. Upload the selected file(s) to the server *
    2. Get all the server HTTP response. *
    3. The stringUploadSuccess regular expression is tested against each * line from the server. *
    4. If the above test gives a match, the upload is marked as successful. * Else, the upload is marked as unsuccessful, and a * JUploadExceptionUploadFailure is thrown. *
    * * @return The regular expression that must be run again each line of the * http answer. */ public String getStringUploadSuccess(); /** * Retrieve the regular expression that will be tested against each line of * the server answer. If one line matches this expression, a warning message * is displayed to the user.
    * * @return The regular expression that must be run again each line of the * http answer. * @see #getStringUploadError() * @see #getStringUploadSuccess() */ public String getStringUploadWarning(); /** * Retrieve the applet's "formdata" parameter. * * @return The applet's formdata parameter. */ public String getFormdata(); /** * Retrieve the applet's "httpUploadParameterName" parameter. * * @return The applet's httpUploadParameterName parameter. */ public String getHttpUploadParameterName(); /** * Retrieve the applet's "httpUploadParameterType" parameter. * * @return The applet's httpUploadParameterType parameter. */ public String getHttpUploadParameterType(); // ////////////////////////////////////////////////////////////////////////////////////////////// // /////////////////// miscellaneous methods // ////////////////////////////////////////////////////////////////////////////////////////////// /** * Reaction by the upload policy, once the management of the dropped file(s) * is finished, that is: after all the dropped files have been successfully * added to the file list. * * @param dropEvent * The event containing the dropped file */ public void afterFileDropped(DropTargetDropEvent dropEvent); // MANAGEMENT OF THE FILE CHOOSER /** * The creation of the file chooser is controled by the upload policy, to * allow fine control of the way to select files. For instance, the * {@link PictureUploadPolicy} creates a file chooser, and add an accessory * to preview pictures. * * @return Return the specific file choose, according to this upload policy. */ public JUploadFileChooser createFileChooser(); /** * This methods is called by the {@link JUploadFileFilter#accept(File)}. It * allows the current upload policy to filter files, according to any * choosen applet behaviour. This filter applied only when using the * fileChooser. Files dropped onto the applet won't trigger this function.
    * In the {@link DefaultUploadPolicy} upload policy, this filter is based on * the applet parameter: allowedFileExtensions. * * @param file * Allows the applet to filter files from the file chooser. * @return true or false, whether the file is accepted or not. * @see JUploadPanel */ public boolean fileFilterAccept(File file); /** * Return a description for the FileFilter, according to the current upload * policy. * * @return A description for the current filter */ public String fileFilterGetDescription(); /** * Response for the {@link JUploadFileView#getIcon(File)}. Default is * implemented in {@link DefaultUploadPolicy#fileViewGetIcon(File)}, by * returning null, which displays the default icon. * * @param file * The file from which the icon should represent. * @return The resulting icon. */ public Icon fileViewGetIcon(File file); /** * This method changes the current mouse cursor to the wait one. It returns * the old one so that, it can be restored, once the work is done. * * @return The cursor that was active, before changing to the wait one. * @see #setCursor(Cursor) */ public Cursor setWaitCursor(); /** * Changes the current mouse cursor. This method can be called at the end of * a big treatement, to restore the cursor returned by the * {@link #setWaitCursor()}. * * @param cursor * The cursor that must be set. * @return The cursor that was active before setting the new one. Can be * used to restore its previous state. */ public Cursor setCursor(Cursor cursor); // ////////////////////////////////////////////////////////////////////////////////////////////// // DISPLAY OF MESSAGES (ERROR, DEBUG ...) // ////////////////////////////////////////////////////////////////////////////////////////////// /** * This method allows the applet to post debug information to the website * (see {@link #getUrlToSendErrorTo()}). Then, it is possible to log the * error, to send a mail... * * @param reason * A string describing briefly the problem. The mail subject will * be something like: Jupload Error (reason) * @param exception * The java exception that was raised, or null if no exception. */ public void sendDebugInformation(String reason, Exception exception); /** * log an error message, based on an exception. Will be logged in the log * window, if defined.
    * The dialog box will only contain an Ok button. Same as caling: * displayErr(e, JOptionPane.OK_OPTION); * * @param e * The exception to report */ public void displayErr(Exception e); /** * log an error message, based on an exception. Will be logged in the log * window, if defined.
    * * @param err * The erreur message to be displayed. If null the exception (or * it's cause if any) message is displayed. * @param e * The exception to report * @param optionType * One of the valid {@link JOptionPane} option types for the * {@link JOptionPane#showConfirmDialog(java.awt.Component, Object, String, int)} * method: OK_CANCEL_OPTION, YES_NO_OPTION, * YES_NO_CANCEL_OPTION... -1 is also accepted, to only have the * Ok button. OK_OPTION is prohibited, as it has the same value * as YES_NO_OPTION. * @return The XXX_OPTION, corresponding to the button clicked by the user. */ public int displayErr(String err, Exception e, int optionType); /** * log an error message. Will be logged in the log window, if defined.
    * The dialog box will only contain an Ok button. * * @param err * The erreur message to be displayed. */ public void displayErr(String err); /** * log an error message. Will be logged in the log window, if defined.
    * The dialog box will only contain an Ok button. * * @param err * The error message to be displayed. * @param e * An exception. It's stacktrace is logged. */ public void displayErr(String err, Exception e); /** * log an info message. Will be logged in the log window, if defined. * * @param info * The information message that will be displayed. */ public void displayInfo(String info); /** * log a warning message. Will be logged in the log window, if defined. * * @param warn * The warning message that will be displayed. */ public void displayWarn(String warn); /** * log a debug message. Will be logged in the log window, if defined. * * @param debug * The message to display. * @param minDebugLevel * If the current debug level is superior or equals to * minDebugLevel, the message will be displayed. Otherwise, it * will be ignored. */ public void displayDebug(String debug, int minDebugLevel); // Others /** * Add an header to the list of headers that will be added to each HTTP * upload request. This method is called from specific uploadPolicies, which * would need headers to be added to all uploads. These headers are used in * {@link wjhk.jupload2.policies.DefaultUploadPolicy}. * * @param header * @see #onAppendHeader(ByteArrayEncoder) */ public void addHeader(String header); /** * Append specific headers for this upload (session cookies, for instance). * This method is called while building each upload HTTP request. * * @param sb * The header {@link ByteArrayEncoder} where specific headers * should be appended. * @return The {@link ByteArrayEncoder} given in parameters. This is allows * to work like with StringBuffer.append method: * sb.append(s1).append(s2); * @throws JUploadIOException * @see #addHeader(String) * @see wjhk.jupload2.upload.FileUploadThread */ public ByteArrayEncoder onAppendHeader(ByteArrayEncoder sb) throws JUploadIOException; /** * This method is called each time a file is selected in the panel files. It * allows, for instance, to preview a picture * {@link wjhk.jupload2.policies.PictureUploadPolicy}. * * @param fileData */ public void onFileSelected(FileData fileData); /** * Reaction when the user double click on a file, in the file list. Default * is no reaction. In {@link PictureUploadPolicy}, it will open a * {@link PictureDialog}. * * @param fileData */ public void onFileDoubleClicked(FileData fileData); /** * Execute any action, that must be done before upload. For instance, * {@link PictureUploadPolicy} disable the rotation buttons during buttons. * The {@link DefaultUploadPolicy#beforeUpload()} method just returns true. * * @return indicate if everything is ready for upload. */ public boolean beforeUpload(); /** * This method returns true, if upload is a success. A HTTP response of "200 * OK" indicates that the server response is techically correct. But, it may * be a functionnal error. For instance, the server could answer by a proper * HTTP page, that the user is no allowed to upload files. It's up to the * uploadPolicy to check this, and answer true or false to this method.
    * This method is called once for each HTTP request toward the server. For * instance, if the upload is done file by file, and there are three files * to upload, this method will be called three times.
    * So this method is different from the * {@link #afterUpload(Exception, String)}, that will be called only once in * this case, after the three calls to the checkUploadSuccess method. * * @param status * The numeric response status (e.g. 200) * @param msg * The status message from the first line of the response (e.g. * "200 OK"). * @param body * The http body part (that is: the serverOuput without the http * headers and the blank line that follow them). * @return true (or an exception is raised, instead of returning false). * This garantees that all cases are handled: the compiler will * indicate an error if the code can come to the end of the method, * without finding a 'return' or a throw exception. This return code * can be ignored by the caller. * @throws JUploadException * Thrown if the success conditions are not met. */ public boolean checkUploadSuccess(int status, String msg, String body) throws JUploadException; /** * This method is called after an upload, whether it is successful or not. * This method is called once for each click of the user on the 'upload' * button. That is: if the nbFilesPerRequest is 2, and the user selected 5 * files before clicking on the 'upload' button. Then the afterUpload is * called once the 5 files were uploaded to the server. * * @param e * null if success, or the exception indicating the problem. * @param serverOutput * The full server output, including the HTTP headers. * @throws JUploadException */ public void afterUpload(Exception e, String serverOutput) throws JUploadException; /** * Returns the current locale. It is the default value at startup, based on * the local computer configuration. Then, if the lang applet parameter is * given, this method the Locale initialized from this lang parameter. * * @return The current Locale for the current policy. */ public Locale getLocale(); /** * Retrieve a lang string, based on the file cointained in the * wjhk.jupload2.lang package. This allows localization. * * @param key * The key, whose associated text is to retrieve. This text must * respect the constraints of the * {@link String#format(String, Object...)} method, that is * called in the * {@link DefaultUploadPolicy#getLocalizedString(String, Object...)} * implementation of this method. * @param args * The optional parameters, that will replace the placeholders in * the localized text identified by 'key'. * @return The associated text. */ public String getLocalizedString(String key, Object... args); /** * Displays a MessageBox with a unique 'Ok' button, by calling the * {@link JOptionPane#showMessageDialog(java.awt.Component, Object)} method. * * @param key * The string identifying the text to display, depending on the * current language. * @see #alertStr(String) */ public void alert(String key); /** * Displays a MessageBox with a unique 'Ok' button, by calling the * {@link JOptionPane#showMessageDialog(java.awt.Component, Object)} method. * * @param str * The full String that must be displayed to the user. * @see #alert(String) */ public void alertStr(String str); /** * Displays a MessageBox with a unique 'Ok' button, by calling the * {@link JOptionPane#showConfirmDialog(java.awt.Component, Object, String, int)} * method. * * @param str * The full String that must be displayed to the user. * @param optionTypes * The options indicating the button to display. Valid options * are the options valid for the * {@link JOptionPane#showConfirmDialog(java.awt.Component, Object, String, int)} * method. * @return The JOptionConstant that indicates the button the user cliecked * on (for instance OK_OPTION) * @see #alert(String) */ public int confirmDialogStr(String str, int optionTypes); /** * Indicates that an error occurs. * * @return The last Exception that occurs in the applet. null if no * exception occurs. */ public JUploadException getLastException(); /** * Retrieve the body of the last server response. * * @return The string containing the last server response (body); */ public String getLastResponseBody(); /** * Retrieve the status/error message of the last server response. * * @return The string containing either the last server status or (if the * error regex matches, the parsed error message. */ public String getLastResponseMessage(); }