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_FILE_LIST_VIEW_MODE, 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_FILE_LIST_VIEW_MODE, 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)
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.
|
FilePanel.FileListViewMode |
getFileListViewMode()
Getter for the fileListViewMode applet parameter.
|
String |
getFilenameEncoding()
Deprecated.
|
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) |
void |
setFileListViewMode(FilePanel.FileListViewMode fileListViewMode)
Setter for the fileListViewMode applet parameter: it can be changed at runtime, by the user.
|
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
debugGenerateFile
protected 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()
UploadPolicy
start
in interface UploadPolicy
UploadPolicy.start()
public void addHeader(String header)
UploadPolicy
DefaultUploadPolicy
.addHeader
in interface UploadPolicy
UploadPolicy.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 UploadPolicy
status
- 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
UploadPolicy
afterUpload
in interface UploadPolicy
e
- null if success, or the exception indicating the problem.serverOutput
- The full server output, including the HTTP headers.JUploadException
UploadPolicy.afterUpload(Exception, String)
public void alertStr(String str)
UploadPolicy
JOptionPane.showMessageDialog(java.awt.Component, Object)
method.alertStr
in interface UploadPolicy
str
- The full String that must be displayed to the user.UploadPolicy.alertStr(String)
public int confirmDialogStr(String str, int optionTypes)
UploadPolicy
JOptionPane.showConfirmDialog(java.awt.Component, Object, String, int)
method.confirmDialogStr
in interface UploadPolicy
str
- 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)
UploadPolicy
JOptionPane.showMessageDialog(java.awt.Component, Object)
method.alert
in interface UploadPolicy
key
- The string identifying the text to display, depending on the current language.UploadPolicy.alert(String)
public FileData createFileData(File file) throws JUploadExceptionStopAddingFiles
createFileData
in interface UploadPolicy
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'.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 UploadPolicy
browse
- 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)
UploadPolicy
createProgressPanel(JProgressBar, JProgressBar, JButton, JButton, JUploadPanel)
.createProgressPanel
in interface UploadPolicy
preparationProgressBar
- 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)
UploadPolicy
createStatusBar(JLabel, JUploadPanel)
.createStatusBar
in interface UploadPolicy
content
- The status bar contentmainPanel
- The panel that contains all objects.UploadPolicy.createStatusBar(javax.swing.JLabel, JUploadPanel)
public void addComponentsToJUploadPanel(JUploadPanel jUploadPanel)
addComponentsToJUploadPanel
in interface UploadPolicy
jUploadPanel
- 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 UploadPolicy
executionStatus
- One of the EXEC_STATUS_XXX constant.public void displayErr(Exception e)
UploadPolicy
displayErr
in interface UploadPolicy
e
- The exception to reportUploadPolicy.displayErr(Exception)
public void displayErr(String err)
UploadPolicy
displayErr
in interface UploadPolicy
err
- The erreur message to be displayed.UploadPolicy.displayErr(String)
public int displayErr(String errorText, Exception exception, int optionTypes)
displayErr
in interface UploadPolicy
errorText
- 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 UploadPolicy
errorText
- 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)
UploadPolicy
displayInfo
in interface UploadPolicy
info
- The information message that will be displayed.UploadPolicy.displayInfo(String)
public void displayWarn(String warn)
UploadPolicy
displayWarn
in interface UploadPolicy
warn
- The warning message that will be displayed.UploadPolicy.displayWarn(String)
public void displayDebug(String debug, int minDebugLevel)
UploadPolicy
displayDebug
in interface UploadPolicy
debug
- 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)
UploadPolicy
getLocalizedString
in interface UploadPolicy
key
- 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
UploadPolicy
getUploadFilename
in interface UploadPolicy
fileData
- 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)JUploadException
UploadPolicy.getUploadFilename(FileData, int)
protected final String getEncodedFilename(String filename) throws JUploadException
filename
- the original filenameJUploadException
public String getUploadName(FileData fileData, int index) throws JUploadException
UploadPolicy
UploadPolicy
, the value for this parameter is controled by the
applet parameters: targetPictureFormat and keepOriginalFileExtensionForConvertedImages.getUploadName
in interface UploadPolicy
fileData
- 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)JUploadException
UploadPolicy.getUploadName(FileData, int)
public String getHttpUploadParameterName()
UploadPolicy
getHttpUploadParameterName
in interface UploadPolicy
UploadPolicy.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()
UploadPolicy
getHttpUploadParameterType
in interface UploadPolicy
UploadPolicy.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.JUploadException
public boolean beforeUpload()
UploadPolicy
PictureUploadPolicy
disable the
rotation buttons during buttons. The beforeUpload()
method just returns true.beforeUpload
in interface UploadPolicy
UploadPolicy.beforeUpload()
public ByteArrayEncoder onAppendHeader(ByteArrayEncoder bae) throws JUploadIOException
UploadPolicy
onAppendHeader
in interface UploadPolicy
bae
- 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);JUploadIOException
UploadPolicy.onAppendHeader(ByteArrayEncoder)
public void onFileSelected(FileData fileData)
UploadPolicy.onFileSelected(wjhk.jupload2.filedata.FileData)
. Nothing's done.onFileSelected
in interface UploadPolicy
public void onFileDoubleClicked(FileData fileData)
UploadPolicy.onFileDoubleClicked(FileData)
.
Nothing's done.onFileDoubleClicked
in interface UploadPolicy
public void sendDebugInformation(String description, Exception exception)
UploadPolicy
UploadPolicy.getUrlToSendErrorTo()
).
Then, it is possible to log the error, to send a mail...sendDebugInformation
in interface UploadPolicy
description
- 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 UploadPolicy
prop
- 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.JUploadException
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.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 UploadPolicy
UploadPolicy.displayParameterStatus()
public String getAfterUploadURL()
UploadPolicy
getAfterUploadURL
in interface UploadPolicy
UploadPolicy.getAfterUploadURL()
protected void setAfterUploadURL(String afterUploadURL) throws JUploadException
afterUploadURL
afterUploadURL
- The URL to use.JUploadException
public boolean getAllowHttpPersistent()
UploadPolicy
getAllowHttpPersistent
in interface UploadPolicy
UploadPolicy.getAllowHttpPersistent()
public String getAllowedFileExtensions()
UploadPolicy
getAllowedFileExtensions
in interface UploadPolicy
UploadPolicy.getAllowedFileExtensions()
protected void setAllowedFileExtensions(String allowedFileExtensions)
allowedFileExtensions
- the allowedFileExtensions to setprotected void setAllowHttpPersistent(boolean value)
public JUploadContext getContext()
UploadPolicy
getContext
in interface UploadPolicy
UploadPolicy.getContext()
public void setCurrentBrowsingDirectory(File currentBrowsingDirectoryParam)
setCurrentBrowsingDirectory
in interface UploadPolicy
currentBrowsingDirectoryParam
- The directory that will be the current one, the next time the file chooser
is opened.UploadPolicy.getCurrentBrowsingDirectory()
public void setCurrentBrowsingDirectory(String currentBrowsingDirectoryParam)
UploadPolicy
setCurrentBrowsingDirectory
in interface UploadPolicy
currentBrowsingDirectoryParam
- The name of the directory that should be the current one.UploadPolicy.setCurrentBrowsingDirectory(String)
public File getCurrentBrowsingDirectory()
UploadPolicy
getCurrentBrowsingDirectory
in interface UploadPolicy
UploadPolicy.getCurrentBrowsingDirectory()
public String getDateFormat()
UploadPolicy
getDateFormat
in interface UploadPolicy
UploadPolicy.getDateFormat()
public int getDebugLevel()
UploadPolicy
getDebugLevel
in interface UploadPolicy
UploadPolicy.getDebugLevel()
public void setDebugLevel(int debugLevel)
UploadPolicy
DefaultUploadPolicy
.addMsgToDebugBufferString
method stores all debug output in a BufferString.setDebugLevel
in interface UploadPolicy
debugLevel
- 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 UploadPolicy
UploadPolicy.PROP_FILE_CHOOSER_ICON_FROM_FILE_CONTENT
public 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_CONTENT
public int getFileChooserIconSize()
getFileChooserIconSize
in interface UploadPolicy
UploadPolicy.PROP_FILE_CHOOSER_ICON_SIZE
public void setFileChooserIconSize(int fileChooserIconSize)
fileChooserIconSize
- Value to be set.IllegalArgumentException
- When a negative value is given.UploadPolicy.PROP_FILE_CHOOSER_ICON_SIZE
public void setLang(String lang)
UploadPolicy
setLang
in interface UploadPolicy
lang
- 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 UploadPolicy
protected String getLookAndFeel()
protected void setLookAndFeel(String lookAndFeel)
lookAndFeel
- the lookAndFeel to setpublic long getMaxChunkSize()
UploadPolicy
getMaxChunkSize
in interface UploadPolicy
UploadPolicy.getMaxChunkSize()
protected void setMaxChunkSize(long maxChunkSize)
maxChunkSize
- the maxChunkSize to setpublic long getMaxFileSize()
UploadPolicy
getMaxFileSize
in interface UploadPolicy
UploadPolicy.getMaxFileSize()
protected void setMaxFileSize(long maxFileSize)
maxFileSize
- the maxFileSize to setpublic int getNbFilesPerRequest()
UploadPolicy
getNbFilesPerRequest
in interface UploadPolicy
UploadPolicy.getNbFilesPerRequest()
protected void setNbFilesPerRequest(int nbFilesPerRequest) throws JUploadException
nbFilesPerRequest
- the nbFilesPerRequest to setJUploadException
public FilePanel.FileListViewMode getFileListViewMode()
UploadPolicy
getFileListViewMode
in interface UploadPolicy
UploadPolicy.getFileListViewMode()
public void setFileListViewMode(FilePanel.FileListViewMode fileListViewMode)
UploadPolicy
setFileListViewMode
in interface UploadPolicy
UploadPolicy.getFileListViewMode()
@Deprecated public String getFilenameEncoding()
UploadPolicy
getFilenameEncoding
in interface UploadPolicy
UploadPolicy.getFilenameEncoding()
public String getFileFilterName()
UploadPolicy
getFileFilterName
in interface UploadPolicy
UploadPolicy.getFileFilterName()
protected void setFileFilterName(String fileFilterName)
fileFilterName
- The new name for the fileFilterUploadPolicy.PROP_FILE_FILTER_NAME
protected void setFilenameEncoding(String filenameEncoding)
filenameEncoding
- the filenameEncoding to setpublic boolean getFtpCreateDirectoryStructure()
UploadPolicy
getFtpCreateDirectoryStructure
in interface UploadPolicy
UploadPolicy.getFtpCreateDirectoryStructure()
protected void setFtpCreateDirectoryStructure(boolean ftpCreateDirectoryStructure)
ftpCreateDirectoryStructure
- the ftpCreateDirectoryStructure to setpublic boolean getFtpTransfertBinary()
UploadPolicy
getFtpTransfertBinary
in interface UploadPolicy
UploadPolicy.getFtpTransfertBinary()
protected void setFtpTransfertBinary(boolean ftpTransfertBinary)
ftpTransfertBinary
- the ftpTransfertBinary to setpublic boolean getFtpTransfertPassive()
UploadPolicy
getFtpTransfertPassive
in interface UploadPolicy
UploadPolicy.getFtpTransfertPassive()
protected void setFtpTransfertPassive(boolean ftpTransfertPassive)
ftpTransfertPassive
- the ftpTransfertPassive to setpublic String getPostURL()
UploadPolicy
getPostURL
in interface UploadPolicy
UploadPolicy.getPostURL()
public void setPostURL(String postURL) throws JUploadException
UploadPolicy
setPostURL
in interface UploadPolicy
JUploadException
UploadPolicy.setPostURL(String)
public boolean getReadCookieFromNavigator()
UploadPolicy
getReadCookieFromNavigator
in interface UploadPolicy
UploadPolicy.getReadCookieFromNavigator()
protected void setReadCookieFromNavigator(boolean readCookieFromNavigator)
public boolean getReadUserAgentFromNavigator()
UploadPolicy
getReadUserAgentFromNavigator
in interface UploadPolicy
UploadPolicy.getReadUserAgentFromNavigator()
protected void setReadUserAgentFromNavigator(boolean readUserAgentFromNavigator)
public int getRetryMaxNumberOf()
UploadPolicy
getRetryMaxNumberOf
in interface UploadPolicy
UploadPolicy.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()
UploadPolicy
getRetryNbSecondsBetween
in interface UploadPolicy
UploadPolicy.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()
UploadPolicy
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. getServerProtocol
in interface UploadPolicy
UploadPolicy.getServerProtocol()
public void setServerProtocol(String serverProtocol)
setServerProtocol
in interface UploadPolicy
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.UploadPolicy.setServerProtocol(String)
public boolean getSendMD5Sum()
UploadPolicy
getSendMD5Sum
in interface UploadPolicy
UploadPolicy.getSendMD5Sum()
public void setSendMD5Sum(boolean sendMD5Sum)
UploadPolicy
setSendMD5Sum
in interface UploadPolicy
sendMD5Sum
- true or false, whether the md5sum should be processed and sent to the server.UploadPolicy.setSendMD5Sum(boolean)
public String getShowLogWindow()
UploadPolicy
getShowLogWindow
in interface UploadPolicy
UploadPolicy.getShowLogWindow()
public void setShowLogWindow(String showLogWindow)
setShowLogWindow
in interface UploadPolicy
showLogWindow
- The show window status to set.UploadPolicy.getShowLogWindow()
public String getSpecificHeaders()
UploadPolicy
getSpecificHeaders
in interface UploadPolicy
UploadPolicy.getSpecificHeaders()
protected void setSpecificHeaders(String specificHeaders)
specificHeaders
- public int getSslVerifyCert()
UploadPolicy
getSslVerifyCert
in interface UploadPolicy
UploadPolicy.getSslVerifyCert()
protected void setSslVerifyCert(String mode) throws JUploadException
JUploadException
protected void setShowStatusbar(boolean show)
show
- the new showStatusbar valuepublic String getStringUploadError()
UploadPolicy
getStringUploadError
in interface UploadPolicy
UploadPolicy.getStringUploadError()
public String getStringUploadSuccess()
UploadPolicy
getStringUploadSuccess
in interface UploadPolicy
UploadPolicy.getStringUploadSuccess()
public String getStringUploadWarning()
UploadPolicy
getStringUploadWarning
in interface UploadPolicy
UploadPolicy.getStringUploadWarning()
protected void setStringUploadError(String stringUploadError) throws JUploadException
stringUploadError
- the stringUploadError to setJUploadException
protected void setStringUploadSuccess(String stringUploadSuccess) throws JUploadException
stringUploadSuccess
- the stringUploadSuccess to setJUploadException
protected void setStringUploadWarning(String stringUploadWarning) throws JUploadException
stringUploadWarning
- the stringUploadWarning to setJUploadException
public String getUrlToSendErrorTo()
UploadPolicy
getUrlToSendErrorTo
in interface UploadPolicy
UploadPolicy.getUrlToSendErrorTo()
public void setUrlToSendErrorTo(String urlToSendErrorTo) throws JUploadException
setUrlToSendErrorTo
in interface UploadPolicy
urlToSendErrorTo
- the urlToSendErrorTo to setJUploadException
public String getFormdata()
UploadPolicy
getFormdata
in interface UploadPolicy
UploadPolicy.getFormdata()
public String getAfterUploadTarget()
UploadPolicy
getAfterUploadTarget
in interface UploadPolicy
UploadPolicy.getAfterUploadTarget()
public void deleteLog()
protected void addMsgToDebugLog(String msg)
msg
- public void afterFileDropped(DropTargetDropEvent dropEvent)
afterFileDropped
in interface UploadPolicy
dropEvent
- The event containing the dropped fileUploadPolicy.afterFileDropped(DropTargetDropEvent)
public JUploadFileChooser createFileChooser()
UploadPolicy.createFileChooser()
: just a creation of a
JUploadFileChooser
.createFileChooser
in interface UploadPolicy
UploadPolicy.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 UploadPolicy
file
- Allows the applet to filter files from the file chooser.UploadPolicy.fileFilterAccept(File)
public String fileFilterGetDescription()
UploadPolicy
fileFilterGetDescription
in interface UploadPolicy
UploadPolicy.fileFilterGetDescription()
public Icon fileViewGetIcon(File file)
fileViewGetIcon
in interface UploadPolicy
file
- The file from which the icon should represent.UploadPolicy.fileViewGetIcon(File)
public JUploadException getLastException()
UploadPolicy
getLastException
in interface UploadPolicy
UploadPolicy.getLastException()
public void setLastException(JUploadException exception)
exception
- The last exception that occurs into the applet.public String getLastResponseBody()
UploadPolicy
getLastResponseBody
in interface UploadPolicy
UploadPolicy.getLastResponseBody()
public String getLastResponseMessage()
UploadPolicy
getLastResponseMessage
in interface UploadPolicy
UploadPolicy.getLastResponseMessage()
public Cursor setCursor(Cursor cursor)
UploadPolicy
UploadPolicy.setWaitCursor()
.setCursor
in interface UploadPolicy
cursor
- The cursor that must be set.UploadPolicy.setCursor(Cursor)
public Cursor setWaitCursor()
UploadPolicy
setWaitCursor
in interface UploadPolicy
UploadPolicy.setWaitCursor()
Copyright © 2015. All rights reserved.