public class DefaultUploadPolicy extends Object implements UploadPolicy
UploadPolicy
methods. Its way of working is he same as the JUpload version 1. UploadPolicy. The DefaultUploadPolicy is used when no
uploadPolicy parameter is given to the juploadContext, or this
parameter has 'DefaultUploadPolicy' as a value.
The default behavior is representated below. It can be overridden by
adding parameters to the juploadContext. All available parameters are shown
in the presentation of UploadPolicy.
UploadPolicy methods.
| Modifier and Type | Field and Description |
|---|---|
protected File |
debugFile
The actual file, used for the debug log.
|
protected boolean |
debugOk
This flag prevents endless repeats of opening the debug log, if that
failed for some reason.
|
protected PrintStream |
debugOut
This stream is used to store all information that could be useful, in
case a problem occurs.
|
static int |
DIALOG_MESSAGE_MAX_LINE_LENGTH
Maximum number of characters allowed for a message that is displayed in a
DialogBox
|
protected String |
httpUploadParameterName
Default value for the httpUploadParameterName applet parameter
|
protected String |
httpUploadParameterType
Default value for the httpUploadParameterType applet parameter
|
protected String |
lastResponseMessage |
protected Pattern |
patternError
Same as
patternSuccess, but for the error message. |
protected Pattern |
patternSuccess
The regexp pattern that is used to find the success string in the HTTP
response.
|
protected Pattern |
patternWarning
Same as
patternSuccess, but for the warning message. |
DEFAULT_AFTER_UPLOAD_TARGET, DEFAULT_AFTER_UPLOAD_URL, DEFAULT_ALBUM_ID, DEFAULT_ALLOW_HTTP_PERSISTENT, DEFAULT_ALLOWED_FILE_EXTENSIONS, DEFAULT_BROWSING_DIRECTORY, DEFAULT_DATE_FORMAT, DEFAULT_DEBUG_LEVEL, DEFAULT_FILE_CHOOSER_ICON_FROM_FILE_CONTENT, DEFAULT_FILE_CHOOSER_ICON_SIZE, DEFAULT_FILE_CHOOSER_IMAGE_PREVIEW, DEFAULT_FILE_FILTER_NAME, DEFAULT_FILENAME_ENCODING, DEFAULT_FORMDATA, DEFAULT_FTP_CREATE_DIRECTORY_STRUCTURE, DEFAULT_FTP_TRANSFERT_BINARY, DEFAULT_FTP_TRANSFERT_PASSIVE, DEFAULT_HIGH_QUALITY_PREVIEW, DEFAULT_HTTP_UPLOAD_PARAMETER_NAME, DEFAULT_HTTP_UPLOAD_PARAMETER_TYPE, DEFAULT_KEEP_ORIG_EXTENSION, DEFAULT_LANG, DEFAULT_LOOK_AND_FEEL, DEFAULT_MAX_CHUNK_SIZE, DEFAULT_MAX_FILE_SIZE, DEFAULT_MAX_HEIGHT, DEFAULT_MAX_WIDTH, DEFAULT_NB_FILES_PER_REQUEST, DEFAULT_PICTURE_COMPRESSION_QUALITY, DEFAULT_PICTURE_TRANSMIT_METADATA, DEFAULT_POST_URL, DEFAULT_READ_COOKIE_FROM_NAVIGATOR, DEFAULT_READ_USER_AGENT_FROM_NAVIGATOR, DEFAULT_REAL_MAX_HEIGHT, DEFAULT_REAL_MAX_WIDTH, DEFAULT_RETRY_MAX_NUMBER_OF, DEFAULT_RETRY_NB_SECONDS_BETWEEN, DEFAULT_SEND_MD5_SUM, DEFAULT_SERVER_PROTOCOL, DEFAULT_SHOW_LOGWINDOW, DEFAULT_SHOW_STATUSBAR, DEFAULT_SPECIFIC_HEADERS, DEFAULT_SSL_VERIFY_CERT, DEFAULT_STORE_BUFFERED_IMAGE, DEFAULT_STRING_UPLOAD_ERROR, DEFAULT_STRING_UPLOAD_SUCCESS, DEFAULT_STRING_UPLOAD_WARNING, DEFAULT_TARGET_PICTURE_FORMAT, DEFAULT_UPLOAD_POLICY, DEFAULT_URL_TO_SEND_ERROR_TO, EXEC_STATUS_READY, EXEC_STATUS_UPLOADING, HTTPUPLOADPARAMETERTYPE_ARRAY, HTTPUPLOADPARAMETERTYPE_ITERATION, HTTPUPLOADPARAMETERTYPE_ONE_FILE, PROP_AFTER_UPLOAD_TARGET, PROP_AFTER_UPLOAD_URL, PROP_ALBUM_ID, PROP_ALLOW_HTTP_PERSISTENT, PROP_ALLOWED_FILE_EXTENSIONS, PROP_BROWSING_DIRECTORY, PROP_DEBUG_LEVEL, PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT, PROP_FILE_CHOOSER_ICON_SIZE, PROP_FILE_CHOOSER_IMAGE_PREVIEW, PROP_FILE_FILTER_NAME, PROP_FILENAME_ENCODING, PROP_FORMDATA, PROP_FTP_CREATE_DIRECTORY_STRUCTURE, PROP_FTP_TRANSFERT_BINARY, PROP_FTP_TRANSFERT_PASSIVE, PROP_HIGH_QUALITY_PREVIEW, PROP_HTTP_UPLOAD_PARAMETER_NAME, PROP_HTTP_UPLOAD_PARAMETER_TYPE, PROP_KEEP_ORIG_EXTENSION, PROP_LANG, PROP_LOOK_AND_FEEL, PROP_MAX_CHUNK_SIZE, PROP_MAX_FILE_SIZE, PROP_MAX_HEIGHT, PROP_MAX_WIDTH, PROP_NB_FILES_PER_REQUEST, PROP_PICTURE_COMPRESSION_QUALITY, PROP_PICTURE_TRANSMIT_METADATA, PROP_POST_URL, PROP_READ_COOKIE_FROM_NAVIGATOR, PROP_READ_USER_AGENT_FROM_NAVIGATOR, PROP_REAL_MAX_HEIGHT, PROP_REAL_MAX_WIDTH, PROP_RETRY_MAX_NUMBER_OF, PROP_RETRY_NB_SECONDS_BETWEEN, PROP_SEND_MD5_SUM, PROP_SERVER_PROTOCOL, PROP_SHOW_LOGWINDOW, PROP_SHOW_STATUSBAR, PROP_SPECIFIC_HEADERS, PROP_SSL_VERIFY_CERT, PROP_STORE_BUFFERED_IMAGE, PROP_STRING_UPLOAD_ERROR, PROP_STRING_UPLOAD_SUCCESS, PROP_STRING_UPLOAD_WARNING, PROP_TARGET_PICTURE_FORMAT, PROP_UPLOAD_POLICY, PROP_URL_TO_SEND_ERROR_TO, SHOWLOGWINDOW_FALSE, SHOWLOGWINDOW_ONERROR, SHOWLOGWINDOW_TRUE| Constructor and Description |
|---|
DefaultUploadPolicy(JUploadContext juploadContext)
The main constructor : use default values, and the given postURL.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addComponentsToJUploadPanel(JUploadPanel jUploadPanel)
This methods allow the upload policy to override the default disposition
of the components on the applet.
|
void |
addHeader(String header)
Add an header to the list of headers that will be added to each HTTP
upload request.
|
protected void |
addMsgToDebugLog(String msg)
This methods allows the applet to store all messages (debug, warning,
info, errors...) into a StringBuffer.
|
void |
afterFileDropped(DropTargetDropEvent dropEvent)
Default reaction after a successful drop operation: no action.
|
void |
afterUpload(Exception e,
String serverOutput)
This method is called after an upload, whether it is successful or not.
|
void |
alert(String key)
Displays a MessageBox with a unique 'Ok' button, by calling the
JOptionPane.showMessageDialog(java.awt.Component, Object) method. |
void |
alertStr(String str)
Displays a MessageBox with a unique 'Ok' button, by calling the
JOptionPane.showMessageDialog(java.awt.Component, Object) method. |
boolean |
beforeUpload()
Execute any action, that must be done before upload.
|
boolean |
checkUploadSuccess(int status,
String msg,
String body)
The default behavior (see
DefaultUploadPolicy) is to check that
the stringUploadSuccess applet parameter is present in the response from
the server. |
int |
confirmDialogStr(String str,
int optionTypes)
Displays a MessageBox with a unique 'Ok' button, by calling the
JOptionPane.showConfirmDialog(java.awt.Component, Object, String, int)
method. |
JUploadFileChooser |
createFileChooser()
Default implementation for
UploadPolicy.createFileChooser(): just
a creation of a JUploadFileChooser. |
FileData |
createFileData(File file,
File root)
The DefaultUpload accepts all file types: we just return an instance of
FileData, without any test.
|
JPanel |
createProgressPanel(JProgressBar preparationProgressBar,
JProgressBar uploadProgressBar,
JButton uploadButton,
JButton stopButton,
JUploadPanel mainPanel)
This method is called to create the progress panel.
|
JPanel |
createStatusBar(JLabel content,
JUploadPanel mainPanel)
This method is used to create a new status bar.
|
JPanel |
createTopPanel(JButton browse,
JButton remove,
JButton removeAll,
JUploadPanel jUploadPanel)
Default implementation of
UploadPolicy.createTopPanel(JButton, JButton, JButton, JUploadPanel)
. |
void |
deleteLog()
Delete the current log.
|
void |
displayDebug(String debug,
int minDebugLevel)
log a debug message.
|
void |
displayErr(Exception e)
log an error message, based on an exception.
|
void |
displayErr(String err)
log an error message.
|
void |
displayErr(String errorText,
Exception exception)
If debug is off, the log window may not be visible.
|
int |
displayErr(String errorText,
Exception exception,
int optionTypes)
If debug is off, the log window may not be visible.
|
void |
displayInfo(String info)
log an info message.
|
void |
displayParameterStatus()
This method displays the applet parameter list, according to the current
debugLevel.
|
void |
displayWarn(String warn)
log a warning message.
|
boolean |
fileFilterAccept(File file)
This method returns the response for the
JUploadFileFilter.accept(File) which just calls this method. |
String |
fileFilterGetDescription()
Return a description for the FileFilter, according to the current upload
policy.
|
Icon |
fileViewGetIcon(File file)
Returns null: the default icon is used.
|
protected String |
formatMessage(String msg)
Generation of a formatted error message, so that it can be displayed in a
DialogBox.
|
String |
getAfterUploadTarget()
Return the target, specified as applet parameter "afterUploadTarget"
|
String |
getAfterUploadURL()
Retrieves the current value for the afterUploadURL applet parameter.
|
String |
getAllowedFileExtensions()
Retrieves the current value for allowedFileExtensions *
|
boolean |
getAllowHttpPersistent()
Retrieves the current value for allowHttpPersistent
|
JUploadContext |
getContext()
A useful function, that has nothing to do with an upload policy.
|
File |
getCurrentBrowsingDirectory()
Returns the current browsing directory, that is: the directory that will
be current the next time the file chooser is opened.
|
String |
getDateFormat()
Returns the currently choosen format for date.
|
int |
getDebugLevel()
This method returns the current debug level.
|
protected String |
getEncodedFilename(String filename)
returns the filename and encodes it, if necessary
|
int |
getFileChooserIconFromFileContent()
Getter for fileChooserIconFromFileContent.
|
int |
getFileChooserIconSize()
Getter for fileChooserIconSize.
|
String |
getFileFilterName()
Getter for the fileFilterName property.
|
String |
getFilenameEncoding()
Returns the encoding that should be used for the filename.
|
String |
getFormdata()
Retrieve the applet's "formdata" parameter.
|
boolean |
getFtpCreateDirectoryStructure()
Returns the current value for the ftpCreateDirectoryStructure applet
parameter.
|
boolean |
getFtpTransfertBinary()
Returns the current value for the ftpTransfertBinary applet parameter.
|
boolean |
getFtpTransfertPassive()
Returns the current value for the ftpTransfertPassive applet parameter.
|
String |
getHttpUploadParameterName()
Retrieve the applet's "httpUploadParameterName" parameter.
|
String |
getHttpUploadParameterType()
Retrieve the applet's "httpUploadParameterType" parameter.
|
JUploadException |
getLastException()
Indicates that an error occurs.
|
String |
getLastResponseBody()
Retrieve the body of the last server response.
|
String |
getLastResponseMessage()
Retrieve the status/error message of the last server response.
|
Locale |
getLocale()
Returns the current locale.
|
String |
getLocalizedString(String key,
Object... args)
Retrieve a lang string, based on the file cointained in the
wjhk.jupload2.lang package.
|
protected String |
getLookAndFeel() |
long |
getMaxChunkSize()
Returns the value of the applet parameter maxChunkSize (see above for a
description of all applet parameters)
|
long |
getMaxFileSize()
Returns the value of the applet parameter maxFileSize (see above for a
description of all applet parameters)
|
int |
getNbFilesPerRequest()
This function returns the number of files should be uploaded during one
access to the server.
|
String |
getPostURL()
Get the target URL for upload.
|
boolean |
getReadCookieFromNavigator()
Return the current value of readCookieFromNavigator
|
boolean |
getReadUserAgentFromNavigator()
Return the current value of readUserAgentFromNavigator
|
int |
getRetryMaxNumberOf()
Return the current value of retryMaxNumberOf
|
int |
getRetryNbSecondsBetween()
Return the current value of retryNbSecondsBetween
|
boolean |
getSendMD5Sum()
MD5Sum allows the server to control that the file has been correctly
uploaded.
|
String |
getServerProtocol()
HTTP protocol that should be used to send the HTTP request.
|
String |
getShowLogWindow()
Indicate whether the log window should be shown.
|
String |
getSpecificHeaders()
Returns the list of specific headers, that will be added to all HTTP
request to the server.
|
int |
getSslVerifyCert()
Retrieves SSL verification mode.
|
String |
getStringUploadError()
Retrieve the regular expression that will be tested against each line of
the server answer.
|
String |
getStringUploadSuccess()
Get the regular expression that will be tested against each line of the
server answer.
|
String |
getStringUploadWarning()
Retrieve the regular expression that will be tested against each line of
the server answer.
|
String |
getUploadFilename(FileData fileData,
int index)
Get the original name of the file on the disk.
|
String |
getUploadName(FileData fileData,
int index)
Get an upload filename, that is to be send in the HTTP upload request.
|
String |
getUrlToSendErrorTo()
Returns the current URL where error log must be posted.
|
ByteArrayEncoder |
onAppendHeader(ByteArrayEncoder bae)
Append specific headers for this upload (session cookies, for instance).
|
void |
onFileDoubleClicked(FileData fileData)
Default implementation of the
UploadPolicy.onFileDoubleClicked(FileData)
. |
void |
onFileSelected(FileData fileData)
Default implementation of the
UploadPolicy.onFileSelected(wjhk.jupload2.filedata.FileData)
. |
void |
sendDebugInformation(String description,
Exception exception)
This method allows the applet to post debug information to the website
(see
UploadPolicy.getUrlToSendErrorTo()). |
protected void |
setAfterUploadURL(String afterUploadURL)
Set the
afterUploadURL |
protected void |
setAllowedFileExtensions(String allowedFileExtensions) |
protected void |
setAllowHttpPersistent(boolean value) |
void |
setCurrentBrowsingDirectory(File currentBrowsingDirectoryParam)
Set the current directory.
|
void |
setCurrentBrowsingDirectory(String currentBrowsingDirectoryParam)
Set the current directory.
|
Cursor |
setCursor(Cursor cursor)
Changes the current mouse cursor.
|
void |
setDebugLevel(int debugLevel)
This method indicate whether or not the debug messages must be displayed.
|
void |
setDebugLevel(int debugLevel,
boolean displayAppletParameterList)
Set the debug level.
|
void |
setFileChooserIconFromFileContent(int fileChooserIconFromFileContent)
Setter for fileChooserIconFromFileContent.
|
void |
setFileChooserIconSize(int fileChooserIconSize)
Setter for fileChooserIconSize.
|
protected void |
setFileFilterName(String fileFilterName) |
protected void |
setFilenameEncoding(String filenameEncoding) |
protected void |
setFtpCreateDirectoryStructure(boolean ftpCreateDirectoryStructure) |
protected void |
setFtpTransfertBinary(boolean ftpTransfertBinary) |
protected void |
setFtpTransfertPassive(boolean ftpTransfertPassive) |
protected void |
setHttpUploadParameterName(String httpUploadParameterName)
Setter for the
httpUploadParameterName. |
protected void |
setHttpUploadParameterType(String httpUploadParameterType)
Setter for the
httpUploadParameterType. |
void |
setLang(String lang)
This method sets the current language to take into account.
|
void |
setLastException(JUploadException exception)
Set the last exception.
|
protected void |
setLookAndFeel(String lookAndFeel) |
protected void |
setMaxChunkSize(long maxChunkSize)
If the given value is less or equals to 0, it is set back to
Long_MAX_VALUE.
|
protected void |
setMaxFileSize(long maxFileSize) |
protected void |
setNbFilesPerRequest(int nbFilesPerRequest) |
void |
setPostURL(String postURL)
The URL can change during the life of our policy ...
|
void |
setProperty(String prop,
String value)
This method manages all applet parameters.
|
protected void |
setReadCookieFromNavigator(boolean readCookieFromNavigator) |
protected void |
setReadUserAgentFromNavigator(boolean readUserAgentFromNavigator) |
void |
setRetryMaxNumberOf(int retryMaxNumberOf) |
void |
setRetryNbSecondsBetween(int retryNbSecondsBetween) |
void |
setSendMD5Sum(boolean sendMD5Sum)
MD5Sum allows the server to control that the file has been correctly
uploaded.
|
void |
setServerProtocol(String serverProtocol) |
void |
setShowLogWindow(String showLogWindow) |
protected void |
setShowStatusbar(boolean show) |
protected void |
setSpecificHeaders(String specificHeaders)
Set all specific headers defined in the specificHeaders applet parameter.
|
protected void |
setSslVerifyCert(String mode) |
protected void |
setStringUploadError(String stringUploadError) |
protected void |
setStringUploadSuccess(String stringUploadSuccess) |
protected void |
setStringUploadWarning(String stringUploadWarning) |
void |
setUrlToSendErrorTo(String urlToSendErrorTo) |
Cursor |
setWaitCursor()
This method changes the current mouse cursor to the wait one.
|
void |
start()
Reaction to the applet start.
|
void |
updateButtonState(int executionStatus)
This method is called by the
JUploadPanel.updateButtonState()
method, when the execution status of the applet changes. |
public static final int DIALOG_MESSAGE_MAX_LINE_LENGTH
protected String httpUploadParameterName
protected String httpUploadParameterType
protected String lastResponseMessage
protected PrintStream debugOut
protected File debugFile
debugGenerateFileprotected boolean debugOk
protected Pattern patternError
patternSuccess, but for the error message. If found,
then the upload was accepted by the remote HTTP server, but rejected by
the remote application. This pattern should also find the error message
in the first matching string.protected Pattern patternSuccess
protected Pattern patternWarning
patternSuccess, but for the warning message. Each time
it is found, a message is displayed to the user.public DefaultUploadPolicy(JUploadContext juploadContext) throws JUploadException
juploadContext - The current juploadContext. As the reference to the current
upload policy exists almost everywhere, this parameter allows
any access to anyone on the juploadContext... including
reading the applet parameters.JUploadException - If an applet parameter is invalidpublic void start()
UploadPolicystart in interface UploadPolicyUploadPolicy.start()public void addHeader(String header)
UploadPolicyDefaultUploadPolicy.addHeader in interface UploadPolicyUploadPolicy.addHeader(java.lang.String)public boolean checkUploadSuccess(int status,
String msg,
String body)
throws JUploadException
DefaultUploadPolicy) is to check that
the stringUploadSuccess applet parameter is present in the response from
the server. The return is tested, in the order below: checkUploadSuccess in interface UploadPolicystatus - The HTTP response codemsg - The status message from the first line of the response (e.g.
"200 OK").body - The body of the HTTP answer.JUploadException - Thrown if the success conditions are not met.UploadPolicy.checkUploadSuccess(int, String, String)protected String formatMessage(String msg)
DIALOG_MESSAGE_MAX_LINE_LENGTH is truncated to
DIALOG_MESSAGE_MAX_LINE_LENGTH.msg - public void afterUpload(Exception e, String serverOutput) throws JUploadException
UploadPolicyafterUpload in interface UploadPolicye - null if success, or the exception indicating the problem.serverOutput - The full server output, including the HTTP headers.JUploadExceptionUploadPolicy.afterUpload(Exception, String)public void alertStr(String str)
UploadPolicyJOptionPane.showMessageDialog(java.awt.Component, Object) method.alertStr in interface UploadPolicystr - The full String that must be displayed to the user.UploadPolicy.alertStr(String)public int confirmDialogStr(String str, int optionTypes)
UploadPolicyJOptionPane.showConfirmDialog(java.awt.Component, Object, String, int)
method.confirmDialogStr in interface UploadPolicystr - The full String that must be displayed to the user.optionTypes - The options indicating the button to display. Valid options
are the options valid for the
JOptionPane.showConfirmDialog(java.awt.Component, Object, String, int)
method.UploadPolicy.confirmDialogStr(String, int)public void alert(String key)
UploadPolicyJOptionPane.showMessageDialog(java.awt.Component, Object) method.alert in interface UploadPolicykey - The string identifying the text to display, depending on the
current language.UploadPolicy.alert(String)public FileData createFileData(File file, File root) throws JUploadExceptionStopAddingFiles
createFileData in interface UploadPolicyfile - 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'.root - An optional toplevel directory of a hierarchy (can be null).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.JUploadExceptionStopAddingFiles - If the users choosed to stop adding. This occurs when the
fileFilterAccept(File) method returns false, and
the user then choose to stop adding files.UploadPolicy.createFileData(File, File)public JPanel createTopPanel(JButton browse, JButton remove, JButton removeAll, JUploadPanel jUploadPanel)
UploadPolicy.createTopPanel(JButton, JButton, JButton, JUploadPanel)
. IT creates a JPanel, containing the three given JButton. It creates the
same panel as the original JUpload.createTopPanel in interface UploadPolicybrowse - The default browse button.remove - The default removeSelected button.removeAll - The default removeAll button.jUploadPanel - The panel that contains all objects.UploadPolicy.createTopPanel(JButton, JButton,
JButton, JUploadPanel)public JPanel createProgressPanel(JProgressBar preparationProgressBar, JProgressBar uploadProgressBar, JButton uploadButton, JButton stopButton, JUploadPanel mainPanel)
UploadPolicycreateProgressPanel(JProgressBar, JProgressBar, JButton, JButton, JUploadPanel)
.createProgressPanel in interface UploadPolicypreparationProgressBar - The default preparation progress bar.uploadProgressBar - The default upload progress bar.uploadButton - The default upload button.stopButton - The default stop button.mainPanel - The panel that contains all objects.UploadPolicy.createProgressPanel(JProgressBar,
JProgressBar, JButton, JButton, JUploadPanel)public JPanel createStatusBar(JLabel content, JUploadPanel mainPanel)
UploadPolicycreateStatusBar(JLabel, JUploadPanel)
.createStatusBar in interface UploadPolicycontent - The status bar contentmainPanel - The panel that contains all objects.UploadPolicy.createStatusBar(javax.swing.JLabel,
JUploadPanel)public void addComponentsToJUploadPanel(JUploadPanel jUploadPanel)
addComponentsToJUploadPanel in interface UploadPolicyjUploadPanel - The main applet panel.UploadPolicy.addComponentsToJUploadPanel(JUploadPanel)public void updateButtonState(int executionStatus)
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.updateButtonState in interface UploadPolicyexecutionStatus - One of the EXEC_STATUS_XXX constant.public void displayErr(Exception e)
UploadPolicydisplayErr in interface UploadPolicye - The exception to reportUploadPolicy.displayErr(Exception)public void displayErr(String err)
UploadPolicydisplayErr in interface UploadPolicyerr - The erreur message to be displayed.UploadPolicy.displayErr(String)public int displayErr(String errorText, Exception exception, int optionTypes)
displayErr in interface UploadPolicyerrorText - The erreur message to be displayed. If null the exception (or
it's cause if any) message is displayed.exception - The exception to reportoptionTypes - One of the valid JOptionPane option types for the
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.UploadPolicy.displayErr(java.lang.String,
java.lang.Exception, int)public void displayErr(String errorText, Exception exception)
displayErr in interface UploadPolicyerrorText - The error message to be displayed.exception - An exception. It's stacktrace is logged.UploadPolicy.displayErr(java.lang.String,
java.lang.Exception)public void displayInfo(String info)
UploadPolicydisplayInfo in interface UploadPolicyinfo - The information message that will be displayed.UploadPolicy.displayInfo(String)public void displayWarn(String warn)
UploadPolicydisplayWarn in interface UploadPolicywarn - The warning message that will be displayed.UploadPolicy.displayWarn(String)public void displayDebug(String debug, int minDebugLevel)
UploadPolicydisplayDebug in interface UploadPolicydebug - The message to display.minDebugLevel - If the current debug level is superior or equals to
minDebugLevel, the message will be displayed. Otherwise, it
will be ignored.UploadPolicy.displayDebug(String, int)public String getLocalizedString(String key, Object... args)
UploadPolicygetLocalizedString in interface UploadPolicykey - The key, whose associated text is to retrieve. This text must
respect the constraints of the
String.format(String, Object...) method, that is
called in the
getLocalizedString(String, Object...)
implementation of this method.args - The optional parameters, that will replace the placeholders in
the localized text identified by 'key'.UploadPolicy.getLocalizedString(String, Object...)public String getUploadFilename(FileData fileData, int index) throws JUploadException
UploadPolicygetUploadFilename in interface UploadPolicyfileData - The file data whose upload file name must be calculated.index - index of the file in the current request to the server (from 0
to n)JUploadExceptionUploadPolicy.getUploadFilename(FileData, int)protected final String getEncodedFilename(String filename) throws JUploadException
filename - the original filenameJUploadExceptionpublic String getUploadName(FileData fileData, int index) throws JUploadException
UploadPolicyUploadPolicy, the value
for this parameter is controled by the applet parameters:
targetPictureFormat and keepOriginalFileExtensionForConvertedImages.getUploadName in interface UploadPolicyfileData - The file data whose upload name must be calculated.index - index of the file in the current request to the server (from 0
to n)JUploadExceptionUploadPolicy.getUploadName(FileData, int)public String getHttpUploadParameterName()
UploadPolicygetHttpUploadParameterName in interface UploadPolicyUploadPolicy.getHttpUploadParameterName()protected void setHttpUploadParameterName(String httpUploadParameterName) throws JUploadException
httpUploadParameterName. This value is used by
the getUploadName(FileData, int) method, to generate the name of
the upload parameter that will contain the uploaded file.JUploadException - When the given value is invalid (null, empty string, or
contains other characters than letters and/or numbers)public String getHttpUploadParameterType()
UploadPolicygetHttpUploadParameterType in interface UploadPolicyUploadPolicy.getHttpUploadParameterType()protected void setHttpUploadParameterType(String httpUploadParameterType) throws JUploadException
httpUploadParameterType. This value is used by
the getUploadName(FileData, int) method, to generate the name of
the upload parameter that will contain the uploaded file. Depending on
this value, the parameter will be an iteration or an array.JUploadExceptionpublic boolean beforeUpload()
UploadPolicyPictureUploadPolicy disable the rotation buttons during buttons.
The beforeUpload() method just returns true.beforeUpload in interface UploadPolicyUploadPolicy.beforeUpload()public ByteArrayEncoder onAppendHeader(ByteArrayEncoder bae) throws JUploadIOException
UploadPolicyonAppendHeader in interface UploadPolicybae - The header ByteArrayEncoder where specific headers
should be appended.ByteArrayEncoder given in parameters. This is allows
to work like with StringBuffer.append method:
sb.append(s1).append(s2);JUploadIOExceptionUploadPolicy.onAppendHeader(ByteArrayEncoder)public void onFileSelected(FileData fileData)
UploadPolicy.onFileSelected(wjhk.jupload2.filedata.FileData)
. Nothing's done.onFileSelected in interface UploadPolicypublic void onFileDoubleClicked(FileData fileData)
UploadPolicy.onFileDoubleClicked(FileData)
. Nothing's done.onFileDoubleClicked in interface UploadPolicypublic void sendDebugInformation(String description, Exception exception)
UploadPolicyUploadPolicy.getUrlToSendErrorTo()). Then, it is possible to log the
error, to send a mail...sendDebugInformation in interface UploadPolicydescription - A string describing briefly the problem. The mail subject will
be something like: Jupload Error (reason)exception - The java exception that was raised, or null if no exception.UploadPolicy.sendDebugInformation(String, Exception)public void setProperty(String prop, String value) throws JUploadException
setProperty in interface UploadPolicyprop - The applet parameter name.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.JUploadExceptionJUploadExceptionStopAddingFiles - 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.UploadPolicy.setProperty(java.lang.String,
java.lang.String)public void displayParameterStatus()
setDebugLevel(int) method. It
should be override by any subclasses, that should display its own
parameters, then call super.displayParameterStatus().displayParameterStatus in interface UploadPolicyUploadPolicy.displayParameterStatus()public String getAfterUploadURL()
UploadPolicygetAfterUploadURL in interface UploadPolicyUploadPolicy.getAfterUploadURL()protected void setAfterUploadURL(String afterUploadURL) throws JUploadException
afterUploadURLafterUploadURL - The URL to use.JUploadExceptionpublic boolean getAllowHttpPersistent()
UploadPolicygetAllowHttpPersistent in interface UploadPolicyUploadPolicy.getAllowHttpPersistent()public String getAllowedFileExtensions()
UploadPolicygetAllowedFileExtensions in interface UploadPolicyUploadPolicy.getAllowedFileExtensions()protected void setAllowedFileExtensions(String allowedFileExtensions)
allowedFileExtensions - the allowedFileExtensions to setprotected void setAllowHttpPersistent(boolean value)
public JUploadContext getContext()
UploadPolicygetContext in interface UploadPolicyUploadPolicy.getContext()public void setCurrentBrowsingDirectory(File currentBrowsingDirectoryParam)
setCurrentBrowsingDirectory in interface UploadPolicycurrentBrowsingDirectoryParam - The directory that will be the current one, the next time the
file chooser is opened.UploadPolicy.getCurrentBrowsingDirectory()public void setCurrentBrowsingDirectory(String currentBrowsingDirectoryParam)
UploadPolicysetCurrentBrowsingDirectory in interface UploadPolicycurrentBrowsingDirectoryParam - The name of the directory that should be the current one.UploadPolicy.setCurrentBrowsingDirectory(String)public File getCurrentBrowsingDirectory()
UploadPolicygetCurrentBrowsingDirectory in interface UploadPolicyUploadPolicy.getCurrentBrowsingDirectory()public String getDateFormat()
UploadPolicygetDateFormat in interface UploadPolicyUploadPolicy.getDateFormat()public int getDebugLevel()
UploadPolicygetDebugLevel in interface UploadPolicyUploadPolicy.getDebugLevel()public void setDebugLevel(int debugLevel)
UploadPolicyDefaultUploadPolicy.addMsgToDebugBufferString method stores all
debug output in a BufferString.setDebugLevel in interface UploadPolicydebugLevel - The new debugLevel.UploadPolicy.setDebugLevel(int)public void setDebugLevel(int debugLevel,
boolean displayAppletParameterList)
debugLevel - The new debuglevel.displayAppletParameterList - Flag. If set to true, the applet's parameters are shown.public int getFileChooserIconFromFileContent()
getFileChooserIconFromFileContent in interface UploadPolicyUploadPolicy.PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENTpublic void setFileChooserIconFromFileContent(int fileChooserIconFromFileContent)
fileChooserIconFromFileContent - Value to be set. If the value is not allowed (not -1, 0 or 1),
the current value is unchangeed.IllegalArgumentException - When a value not in -1, 0 1 is given.UploadPolicy.PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENTpublic int getFileChooserIconSize()
getFileChooserIconSize in interface UploadPolicyUploadPolicy.PROP_FILE_CHOOSER_ICON_SIZEpublic void setFileChooserIconSize(int fileChooserIconSize)
fileChooserIconSize - Value to be set.IllegalArgumentException - When a negative value is given.UploadPolicy.PROP_FILE_CHOOSER_ICON_SIZEpublic void setLang(String lang)
UploadPolicysetLang in interface UploadPolicylang - The new language to take into account. See the
java.util.Locale(String) constructor for a list of valid
values.UploadPolicy.setLang(String)public Locale getLocale()
getLocale in interface UploadPolicyprotected String getLookAndFeel()
protected void setLookAndFeel(String lookAndFeel)
lookAndFeel - the lookAndFeel to setpublic long getMaxChunkSize()
UploadPolicygetMaxChunkSize in interface UploadPolicyUploadPolicy.getMaxChunkSize()protected void setMaxChunkSize(long maxChunkSize)
maxChunkSize - the maxChunkSize to setpublic long getMaxFileSize()
UploadPolicygetMaxFileSize in interface UploadPolicyUploadPolicy.getMaxFileSize()protected void setMaxFileSize(long maxFileSize)
maxFileSize - the maxFileSize to setpublic int getNbFilesPerRequest()
UploadPolicygetNbFilesPerRequest in interface UploadPolicyUploadPolicy.getNbFilesPerRequest()protected void setNbFilesPerRequest(int nbFilesPerRequest)
throws JUploadException
nbFilesPerRequest - the nbFilesPerRequest to setJUploadExceptionpublic String getFilenameEncoding()
UploadPolicygetFilenameEncoding in interface UploadPolicyUploadPolicy.getFilenameEncoding()public String getFileFilterName()
UploadPolicygetFileFilterName in interface UploadPolicyUploadPolicy.getFileFilterName()protected void setFileFilterName(String fileFilterName)
fileFilterName - The new name for the fileFilterUploadPolicy.PROP_FILE_FILTER_NAMEprotected void setFilenameEncoding(String filenameEncoding)
filenameEncoding - the filenameEncoding to setpublic boolean getFtpCreateDirectoryStructure()
UploadPolicygetFtpCreateDirectoryStructure in interface UploadPolicyUploadPolicy.getFtpCreateDirectoryStructure()protected void setFtpCreateDirectoryStructure(boolean ftpCreateDirectoryStructure)
ftpCreateDirectoryStructure - the ftpCreateDirectoryStructure to setpublic boolean getFtpTransfertBinary()
UploadPolicygetFtpTransfertBinary in interface UploadPolicyUploadPolicy.getFtpTransfertBinary()protected void setFtpTransfertBinary(boolean ftpTransfertBinary)
ftpTransfertBinary - the ftpTransfertBinary to setpublic boolean getFtpTransfertPassive()
UploadPolicygetFtpTransfertPassive in interface UploadPolicyUploadPolicy.getFtpTransfertPassive()protected void setFtpTransfertPassive(boolean ftpTransfertPassive)
ftpTransfertPassive - the ftpTransfertPassive to setpublic String getPostURL()
UploadPolicygetPostURL in interface UploadPolicyUploadPolicy.getPostURL()public void setPostURL(String postURL) throws JUploadException
UploadPolicysetPostURL in interface UploadPolicyJUploadExceptionUploadPolicy.setPostURL(String)public boolean getReadCookieFromNavigator()
UploadPolicygetReadCookieFromNavigator in interface UploadPolicyUploadPolicy.getReadCookieFromNavigator()protected void setReadCookieFromNavigator(boolean readCookieFromNavigator)
public boolean getReadUserAgentFromNavigator()
UploadPolicygetReadUserAgentFromNavigator in interface UploadPolicyUploadPolicy.getReadUserAgentFromNavigator()protected void setReadUserAgentFromNavigator(boolean readUserAgentFromNavigator)
public int getRetryMaxNumberOf()
UploadPolicygetRetryMaxNumberOf in interface UploadPolicyUploadPolicy.getRetryMaxNumberOf()public void setRetryMaxNumberOf(int retryMaxNumberOf)
retryMaxNumberOf - New value to set for the retryMaxNumberOf applet parameterIllegalArgumentException - If retryMaxNumberOf is less than 0.UploadPolicy.getRetryMaxNumberOf()public int getRetryNbSecondsBetween()
UploadPolicygetRetryNbSecondsBetween in interface UploadPolicyUploadPolicy.getRetryNbSecondsBetween()public void setRetryNbSecondsBetween(int retryNbSecondsBetween)
retryNbSecondsBetween - New value to set for the retryNbSecondsBetween applet
parameterIllegalArgumentException - If retryNbSecondsBetween is less than 0.UploadPolicy.getRetryNbSecondsBetween()public String getServerProtocol()
UploadPolicyCoppermineUploadPolicy, 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. getServerProtocol in interface UploadPolicyUploadPolicy.getServerProtocol()public void setServerProtocol(String serverProtocol)
setServerProtocol in interface UploadPolicyserverProtocol - 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.UploadPolicy.setServerProtocol(String)public boolean getSendMD5Sum()
UploadPolicygetSendMD5Sum in interface UploadPolicyUploadPolicy.getSendMD5Sum()public void setSendMD5Sum(boolean sendMD5Sum)
UploadPolicysetSendMD5Sum in interface UploadPolicysendMD5Sum - true or false, whether the md5sum should be processed and sent
to the server.UploadPolicy.setSendMD5Sum(boolean)public String getShowLogWindow()
UploadPolicygetShowLogWindow in interface UploadPolicyUploadPolicy.getShowLogWindow()public void setShowLogWindow(String showLogWindow)
setShowLogWindow in interface UploadPolicyshowLogWindow - The show window status to set.UploadPolicy.getShowLogWindow()public String getSpecificHeaders()
UploadPolicygetSpecificHeaders in interface UploadPolicyUploadPolicy.getSpecificHeaders()protected void setSpecificHeaders(String specificHeaders)
specificHeaders - public int getSslVerifyCert()
UploadPolicygetSslVerifyCert in interface UploadPolicyUploadPolicy.getSslVerifyCert()protected void setSslVerifyCert(String mode) throws JUploadException
JUploadExceptionprotected void setShowStatusbar(boolean show)
show - the new showStatusbar valuepublic String getStringUploadError()
UploadPolicygetStringUploadError in interface UploadPolicyUploadPolicy.getStringUploadError()public String getStringUploadSuccess()
UploadPolicygetStringUploadSuccess in interface UploadPolicyUploadPolicy.getStringUploadSuccess()public String getStringUploadWarning()
UploadPolicygetStringUploadWarning in interface UploadPolicyUploadPolicy.getStringUploadWarning()protected void setStringUploadError(String stringUploadError) throws JUploadException
stringUploadError - the stringUploadError to setJUploadExceptionprotected void setStringUploadSuccess(String stringUploadSuccess) throws JUploadException
stringUploadSuccess - the stringUploadSuccess to setJUploadExceptionprotected void setStringUploadWarning(String stringUploadWarning) throws JUploadException
stringUploadWarning - the stringUploadWarning to setJUploadExceptionpublic String getUrlToSendErrorTo()
UploadPolicygetUrlToSendErrorTo in interface UploadPolicyUploadPolicy.getUrlToSendErrorTo()public void setUrlToSendErrorTo(String urlToSendErrorTo) throws JUploadException
setUrlToSendErrorTo in interface UploadPolicyurlToSendErrorTo - the urlToSendErrorTo to setJUploadExceptionpublic String getFormdata()
UploadPolicygetFormdata in interface UploadPolicyUploadPolicy.getFormdata()public String getAfterUploadTarget()
UploadPolicygetAfterUploadTarget in interface UploadPolicyUploadPolicy.getAfterUploadTarget()public void deleteLog()
protected void addMsgToDebugLog(String msg)
msg - public void afterFileDropped(DropTargetDropEvent dropEvent)
afterFileDropped in interface UploadPolicydropEvent - The event containing the dropped fileUploadPolicy.afterFileDropped(DropTargetDropEvent)public JUploadFileChooser createFileChooser()
UploadPolicy.createFileChooser(): just
a creation of a JUploadFileChooser.createFileChooser in interface UploadPolicyUploadPolicy.createFileChooser()public boolean fileFilterAccept(File file)
JUploadFileFilter.accept(File) which just calls this method. This
method checks that the file extension corresponds to the
allowedFileExtensions applet parameter.fileFilterAccept in interface UploadPolicyfile - Allows the applet to filter files from the file chooser.UploadPolicy.fileFilterAccept(File)public String fileFilterGetDescription()
UploadPolicyfileFilterGetDescription in interface UploadPolicyUploadPolicy.fileFilterGetDescription()public Icon fileViewGetIcon(File file)
fileViewGetIcon in interface UploadPolicyfile - The file from which the icon should represent.UploadPolicy.fileViewGetIcon(File)public JUploadException getLastException()
UploadPolicygetLastException in interface UploadPolicyUploadPolicy.getLastException()public void setLastException(JUploadException exception)
exception - The last exception that occurs into the applet.public String getLastResponseBody()
UploadPolicygetLastResponseBody in interface UploadPolicyUploadPolicy.getLastResponseBody()public String getLastResponseMessage()
UploadPolicygetLastResponseMessage in interface UploadPolicyUploadPolicy.getLastResponseMessage()public Cursor setCursor(Cursor cursor)
UploadPolicyUploadPolicy.setWaitCursor().setCursor in interface UploadPolicycursor - The cursor that must be set.UploadPolicy.setCursor(Cursor)public Cursor setWaitCursor()
UploadPolicysetWaitCursor in interface UploadPolicyUploadPolicy.setWaitCursor()Copyright © 2012. All Rights Reserved.