com.ibm.commerce.command
Class TempUploadCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.ControllerCommandImpl
                    |
                    +--com.ibm.commerce.command.TempUploadCmdImpl
All Implemented Interfaces:
AccCommand, ControllerCommand, ECCommand, ECTargetableCommand, TempUploadCmd
Direct Known Subclasses:
WebAssetsUploadCmdImpl

public class TempUploadCmdImpl
extends ControllerCommandImpl
implements TempUploadCmd

The TempUploadCmd will upload File to a file system with a unique generated filename Note that this is not registered in URLREG or CMDREG, TempUPloadCmd is not intended to be used directly , it should be extended by other commands The upload path to be uploaded is $wcsstore\storename\filepath $wcsstore is defined in instance configuration file storename is based on store_id retrieved from command context , i.e. the store user logs in filepath is user specified subdirectories the uploaded filename is a unique generated filename

See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
          IBM Copyright notice field.
 
Fields inherited from class com.ibm.commerce.command. ControllerCommandImpl
requestProperties, responseProperties, retriable, viewReqProperties
 
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.command. TempUploadCmd
defaultCommandClassName
 
Constructor Summary
TempUploadCmdImpl()
           
 
Method Summary
 java.lang.String constructFileString()
          To construct the attachmenturl
 long getAttachmentOwner()
          Gets the creator of uploaded attachment the user who logs on to the store.
 java.lang.String getAttachmentURL()
          Gets the attachmentURL of the uploaded file
protected  java.lang.String getContentType()
          Gets the contenttype of uploaded attachment
 java.lang.String getErrorURL()
          Gets the errorURL to be redirected when an error occurs during upload
protected  java.lang.String getFileExtension()
          Gets the file extension
protected  java.lang.String getFileName_NoExt()
          Gets the filename with no extension
 java.lang.String getFileName()
          Gets the fileName of uplaoded file
 java.lang.String getFilePath()
          Gets the filepath (after the predefined path ) of the attachment to be uploaded.
 long getFileSize()
          Gets the filesize of upload file
 java.lang.String getRename()
          Gets the rename if the uploaded file
 java.lang.String getRootPath()
          Gets the rootPath of where the file should be uploaded .
 java.lang.String getStoreName()
          Gets the storeName from command context .
 java.lang.String getUrl()
          Gets the Url to be returned when upload is completed .
 void performExecute()
          This method contains the main business logic of this command.
 void setErrorURL(java.lang.String errorURL)
          Sets the errorURL to be forwarded when an error occurs during upload
 void setFilePath(java.lang.String path)
          Sets the subdirectories (after the predefined path) of the attachment to be uploaded.
 void setRefCmd(java.lang.String name)
          Sets the refcmd of the the command which extends the base TempUpload.
 void setRename(java.lang.String name)
          Sets the name that user rename the uploaded file
 void setRequestProperties( TypedProperty reqParms)
          Sets the request properties
 void setRootPath(java.lang.String path)
          Sets the rootPath of where the file should be uploaded .
 void setUrl(java.lang.String returnURL)
          Sets the Url to be returned/redriected when upload is completed .
 void validateParameters()
          Checks the validity of the parameters.
 
Methods inherited from class com.ibm.commerce.command. ControllerCommandImpl
checkPermission, fulfills, getForUserId, getGeneric, getOwner, getRequestProperties, getResolvedRequestProperties, getResourceOwners, getResponseProperties, getRetriable, getViewInputProperties, isGeneric, isRetriable, mergeProperties, setForUserId, setGeneric, setOwner, setResponseProperties, setRetriable, setViewInputProperties
 
Methods inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
accessControlCheck, checkIsAllowed, checkParameters, checkResourcePermission, createCommandExecutionEvent, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, reset, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.commerce.command. ControllerCommand
checkPermission, execute, getGeneric, getRequestProperties, getResolvedRequestProperties, getResponseProperties, getRetriable, getViewInputProperties, isGeneric, isRetriable, mergeProperties, setGeneric, setRetriable, setViewInputProperties
 
Methods inherited from interface com.ibm.commerce.command. AccCommand
accessControlCheck, getAccCheck, getForUserId, getResourceOwners, setAccCheck, setForUserId, setOwner
 
Methods inherited from interface com.ibm.commerce.command. ECCommand
checkIsAllowed, checkResourcePermission, createCommandExecutionEvent, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getResources, getStoreId, getUser, getUserId, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
 

Field Detail
public static final java.lang.String COPYRIGHT
IBM Copyright notice field.
See Also:
Constant Field Values
Constructor Detail

TempUploadCmdImpl

public TempUploadCmdImpl()
Method Detail

getAttachmentURL

public java.lang.String getAttachmentURL()
Gets the attachmentURL of the uploaded file
Specified by:
getAttachmentURL in interface TempUploadCmd
Returns:
String - attachmentURL

setErrorURL

public void setErrorURL(java.lang.String errorURL)
Sets the errorURL to be forwarded when an error occurs during upload

setFilePath

public void setFilePath(java.lang.String path)
Sets the subdirectories (after the predefined path) of the attachment to be uploaded. The predefined path = rootpath\storename e.g. if xml file rootpath= drive:\WebSphere\AppServer\InstalledApps\wcsstores.war\xml else rootpath=drive:\WebSphere\AppServer\InstalledApps\wcsstores.war\

getFilePath

public java.lang.String getFilePath()
Gets the filepath (after the predefined path ) of the attachment to be uploaded.
Returns:
String - filepath

setRefCmd

public void setRefCmd(java.lang.String name)
Sets the refcmd of the the command which extends the base TempUpload. The refcmd should match the command name in attachment configuration in instance.xml file and it should be the commandName in the command context, ie. the URL command that extends the tempuploadCmd
Parameters:
name - String - component command name

setRename

public void setRename(java.lang.String name)
Sets the name that user rename the uploaded file
Parameters:
name - String - the rename of uploaded file name

setUrl

public void setUrl(java.lang.String returnURL)
Sets the Url to be returned/redriected when upload is completed .

getRename

public java.lang.String getRename()
Gets the rename if the uploaded file
Returns:
String - uplaoded file new name

setRootPath

public void setRootPath(java.lang.String path)
Sets the rootPath of where the file should be uploaded .

getRootPath

public java.lang.String getRootPath()
Gets the rootPath of where the file should be uploaded .
Returns:
String - rootpath

getStoreName

public java.lang.String getStoreName()
Gets the storeName from command context .
Returns:
String - storeName

getFileName

public java.lang.String getFileName()
Gets the fileName of uplaoded file
Specified by:
getFileName in interface TempUploadCmd
Returns:
String - fileName

getUrl

public java.lang.String getUrl()
Gets the Url to be returned when upload is completed .
Specified by:
getUrl in interface TempUploadCmd
Returns:
String - Url

getErrorURL

public java.lang.String getErrorURL()
Gets the errorURL to be redirected when an error occurs during upload
Returns:
errorURL the url to be redirected when an error occurs

getFileSize

public long getFileSize()
Gets the filesize of upload file
Specified by:
getFileSize in interface TempUploadCmd
Returns:
filesize the size of the uploaded file

getAttachmentOwner

public long getAttachmentOwner()
Gets the creator of uploaded attachment the user who logs on to the store.
Specified by:
getAttachmentOwner in interface TempUploadCmd
Returns:
owner_id the user who uploads the attachment

getContentType

protected java.lang.String getContentType()
Gets the contenttype of uploaded attachment
Returns:
contenttype the contenttype of the uploaded file

getFileName_NoExt

protected java.lang.String getFileName_NoExt()
Gets the filename with no extension
Returns:
filename without extension

getFileExtension

protected java.lang.String getFileExtension()
Gets the file extension
Returns:
file extension

setRequestProperties

public void setRequestProperties(TypedProperty reqParms)
                          throws ECException
Sets the request properties

will set up all the request parameters e.g. refcmd, filepath,rename,filename,errorURL,Url from the URL gets user_id, store_id from command context gets the configurable paremeters maxuploadsize,viruscheck,supportedfile extension from instance.xml based on refcmd

Specified by:
setRequestProperties in interface ControllerCommand
Overrides:
setRequestProperties in class ControllerCommandImpl
Parameters:
reqParms - the requested parameters
Throws:
ECException
See Also:
ControllerComand#performExecute

validateParameters

public void validateParameters()
                        throws ECException
Checks the validity of the parameters. It checks for the presence or absence of parameters and the range of values.
Specified by:
validateParameters in interface ECCommand
Overrides:
validateParameters in class AbstractECTargetableCommand
Throws:
ECException - Raised with exception ECMessage._ERR_UPLOAD_MISSING_REFCMD when the refcmd is missing in instance file attachment configuration section Raised with exception ECMessage._ERR_UPLOAD_FILECONTENTTYPE_NOTALLOWED when the contenttpye of upload file does not match with file extension Raised with exception ECMessage._ERR_UPLOAD_FILETYPE_NOTALLOWED when the file type is not one of the supportedfileextension specified in attachment configuration Raised with exception ECMessage._ERR_UPLOAD_FILESIZE_TOOBIG when the filesize exceeds the maximum allowable size in the attachment configuration in instance file

constructFileString

public java.lang.String constructFileString()
To construct the attachmenturl

performExecute

public void performExecute()
                    throws ECException
This method contains the main business logic of this command. It will generate a unique filename and uploaded the file
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
ECException
See Also:
ECComand#performExecute