wjhk.jupload2.policies
Class CoppermineUploadPolicy

java.lang.Object
  extended by wjhk.jupload2.policies.DefaultUploadPolicy
      extended by wjhk.jupload2.policies.PictureUploadPolicy
          extended by wjhk.jupload2.policies.CoppermineUploadPolicy
All Implemented Interfaces:
ActionListener, ImageObserver, EventListener, UploadPolicy

public class CoppermineUploadPolicy
extends PictureUploadPolicy

Specific UploadPolicy for the coppermine picture gallery. It is based on the PictureUploadPolicy, and some specific part to add the uploaded pictures to a coppermine existing album.
Specific features for this policy are:

Call of the applet from a php script in coppermine

You'll find below an example of how to put the applet into a PHP page:
<?php $URL = $CONFIG['site_url'] . 'xp_publish.php'; $lang = $lang_translation_info['lang_country_code']; $max_upl_width_height = $CONFIG['max_upl_width_height']; ?> <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 call some javascript function, so we must allow it : --> MAYSCRIPT > <!-- First, mandatory parameters --> <PARAM NAME="postURL" VALUE="$URL"> <PARAM NAME="uploadPolicy" VALUE="CoppermineUploadPolicy"> <!-- Then, optional parameters --> <PARAM NAME="lang" VALUE="$lang"> <PARAM NAME="maxPicHeight" VALUE="$max_upl_width_height"> <PARAM NAME="maxPicWidth" VALUE="$max_upl_width_height"> <PARAM NAME="debugLevel" VALUE="0"> Java 1.4 or higher plugin required. </APPLET>

Example 2: albumId set by a javascript call.

<script language="javascript" type="text/javascript"> function onAlbumChange() { if (document.form_album.album_id.selectedIndex >= 0) { document.applets['JUpload'].setProperty('albumId', document.form_album.album_id.value); document.form_album.album_name.value = document .form_album.album_id.options[document.form_album.album_id.selectedIndex ].text; document.form_album.album_description.value = description[document.form_album.album_id.value]; } else { document.JUpload.setProperty('albumId', ''); document.form_album.album_name.value = ''; document.form_album.album_description.value = ''; } } </script>

Version:
$Revision: 870 $
Author:
etienne_sf

Field Summary
 
Fields inherited from class wjhk.jupload2.policies.DefaultUploadPolicy
cookie, debugFile, debugOk, debugOut, patternError, patternSuccess, patternWarning, userAgent
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Fields inherited from interface wjhk.jupload2.policies.UploadPolicy
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_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_REAL_MAX_HEIGHT, DEFAULT_REAL_MAX_WIDTH, 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, 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_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_REAL_MAX_HEIGHT, PROP_REAL_MAX_WIDTH, 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 Summary
CoppermineUploadPolicy(wjhk.jupload2.context.JUploadContext juploadContext)
           
 
Method Summary
 void afterUpload(Exception e, String serverOutput)
          This method is called after an upload, whether it is successful or not.
 boolean beforeUpload()
          This method checks that an album id has been given, and then stores the number of files that are to be uploaded, before upload, then call its superclass.
 void displayParameterStatus()
          This method displays the applet parameter list, according to the current debugLevel.
 String getPostURL()
          Get the target URL for upload.
 void onFileSelected(FileData fileData)
          Default implementation of the UploadPolicy.onFileSelected(wjhk.jupload2.filedata.FileData) .
 void setProperty(String prop, String value)
          This method only handles the albumId parameter, which is the only applet parameter that is specific to this class.
 
Methods inherited from class wjhk.jupload2.policies.PictureUploadPolicy
actionPerformed, createFileChooser, createFileData, createTopPanel, fileViewGetIcon, getFileChooserImagePreview, getHighQualityPreview, getImageFileConversionInfo, getKeepOrigExtension, getMaxHeight, getMaxWidth, getPictureCompressionQuality, getPictureTransmitMetadata, getRealMaxHeight, getRealMaxWidth, getTargetPictureFormat, getUploadFilename, imageUpdate, onFileDoubleClicked, setCursor, setFileChooserImagePreview, setHighQualityPreview, setKeepOrigExtension, setMaxHeight, setMaxWidth, setPictureCompressionQuality, setPictureTransmitMetadata, setRealMaxHeight, setRealMaxWidth, setTargetPictureFormat, setWaitCursor
 
Methods inherited from class wjhk.jupload2.policies.DefaultUploadPolicy
addComponentsToJUploadPanel, addHeader, addMsgToDebugLog, afterFileDropped, alert, alertStr, checkUploadSuccess, createProgressPanel, createStatusBar, deleteLog, displayDebug, displayErr, displayErr, displayErr, displayInfo, displayWarn, fileFilterAccept, fileFilterGetDescription, getAfterUploadTarget, getAfterUploadURL, getAllowedFileExtensions, getAllowHttpPersistent, getContext, getCurrentBrowsingDirectory, getDateFormat, getDebugLevel, getEncodedFilename, getFileChooserIconFromFileContent, getFileChooserIconSize, getFilenameEncoding, getFormdata, getFtpCreateDirectoryStructure, getFtpTransfertBinary, getFtpTransfertPassive, getHttpUploadParameterName, getHttpUploadParameterType, getLastException, getLastResponseBody, getLastResponseMessage, getLookAndFeel, getMaxChunkSize, getMaxFileSize, getNbFilesPerRequest, getReadCookieFromNavigator, getServerProtocol, getShowLogWindow, getSpecificHeaders, getSslVerifyCert, getString, getStringUploadError, getStringUploadSuccess, getStringUploadWarning, getUploadName, getUrlToSendErrorTo, onAppendHeader, sendDebugInformation, setAfterUploadURL, setAllowedFileExtensions, setAllowHttpPersistent, setCurrentBrowsingDirectory, setCurrentBrowsingDirectory, setDebugLevel, setDebugLevel, setFileChooserIconFromFileContent, setFileChooserIconSize, setFilenameEncoding, setFtpCreateDirectoryStructure, setFtpTransfertBinary, setFtpTransfertPassive, setLang, setLastException, setLookAndFeel, setMaxChunkSize, setMaxFileSize, setNbFilesPerRequest, setPostURL, setServerProtocol, setShowLogWindow, setShowStatusbar, setSpecificHeaders, setSslVerifyCert, setStringUploadError, setStringUploadSuccess, setStringUploadWarning, setUrlToSendErrorTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CoppermineUploadPolicy

public CoppermineUploadPolicy(wjhk.jupload2.context.JUploadContext juploadContext)
                       throws JUploadException
Parameters:
juploadContext - Identifier for the current applet. It's necessary, to read information from the navigator.
Throws:
JUploadException
Method Detail

onFileSelected

public void onFileSelected(FileData fileData)
Description copied from class: DefaultUploadPolicy
Default implementation of the UploadPolicy.onFileSelected(wjhk.jupload2.filedata.FileData) . Nothing's done.

Specified by:
onFileSelected in interface UploadPolicy
Overrides:
onFileSelected in class PictureUploadPolicy
See Also:
UploadPolicy.onFileSelected(wjhk.jupload2.filedata.FileData)

setProperty

public void setProperty(String prop,
                        String value)
                 throws JUploadException
This method only handles the albumId parameter, which is the only applet parameter that is specific to this class. The super.setProperty method is called for other properties.

Specified by:
setProperty in interface UploadPolicy
Overrides:
setProperty in class PictureUploadPolicy
Parameters:
prop - The property which value should change
value - The new value for this property. If invalid, the default value is used.
Throws:
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.
See Also:
UploadPolicy.setProperty(java.lang.String, java.lang.String)

getPostURL

public String getPostURL()
Description copied from interface: UploadPolicy
Get the target URL for upload.

Specified by:
getPostURL in interface UploadPolicy
Overrides:
getPostURL in class DefaultUploadPolicy
Returns:
Should be valid URL...
See Also:
UploadPolicy.getPostURL()

beforeUpload

public boolean beforeUpload()
This method checks that an album id has been given, and then stores the number of files that are to be uploaded, before upload, then call its superclass. This number is then used to display to the user the list of pictures he just uploaded.

Specified by:
beforeUpload in interface UploadPolicy
Overrides:
beforeUpload in class PictureUploadPolicy
Returns:
indicate if everything is ready for upload.
See Also:
UploadPolicy.beforeUpload()

afterUpload

public void afterUpload(Exception e,
                        String serverOutput)
                 throws JUploadException
Description copied from interface: UploadPolicy
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.

Specified by:
afterUpload in interface UploadPolicy
Overrides:
afterUpload in class DefaultUploadPolicy
Parameters:
e - null if success, or the exception indicating the problem.
serverOutput - The full server output, including the HTTP headers.
Throws:
JUploadException
See Also:
UploadPolicy.afterUpload(Exception, String)

displayParameterStatus

public void displayParameterStatus()
Description copied from class: DefaultUploadPolicy
This method displays the applet parameter list, according to the current debugLevel. It is called by the DefaultUploadPolicy.setDebugLevel(int) method. It should be override by any subclasses, that should display its own parameters, then call super.displayParameterStatus().

Specified by:
displayParameterStatus in interface UploadPolicy
Overrides:
displayParameterStatus in class PictureUploadPolicy
See Also:
DefaultUploadPolicy.displayParameterStatus()