com.ibm.commerce.command
Class UploadToStreamCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.ControllerCommandImpl
                    |
                    +--com.ibm.commerce.command.UploadToStreamCmdImpl
All Implemented Interfaces:
AccCommand, ControllerCommand, ECCommand, ECTargetableCommand, UploadToStreamCmd
Direct Known Subclasses:
AttachmentUploadCmdImpl, ContractUploadCmdImpl

public class UploadToStreamCmdImpl
extends ControllerCommandImpl
implements UploadToStreamCmd

The UploadToStreamCmdImpl will upload files to return a stream. Note that this is not registered in URLREG, UploadToStreamCmd is not intended to be used directly , it should be extended by other commands

See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
          IBM Copyright.
 
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. UploadToStreamCmd
defaultCommandClassName
 
Constructor Summary
UploadToStreamCmdImpl()
           
 
Method Summary
 long getAttachmentOwner()
          Gets the owner_id of the attachment creator
 java.io.InputStream getAttachmentStream()
          Gets the uploaded attachment Stream
protected  java.lang.String getContentType()
          Gets the contentType of the uploaded file *
 java.lang.String getErrorURL()
          Gets the Url to be redirected when upload runs into error .
protected  java.lang.String getFileExtension()
          Gets the file extension of the attachment file
protected  java.lang.String getFileName_NoExt()
          Gets the filename without extension
 java.lang.String getFileName()
          Gets the filename of the uploaded attachment
 long getFileSize()
          Gets the filesize of uploaded file
 java.lang.String getRootPath()
          Gets the rootPath of where the file should be uploaded .
protected  java.lang.String getStoreName()
          Gets the storename.
 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 setRefCmd(java.lang.String name)
          Sets the refcmd of the the command which extends this command.
 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 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.
See Also:
Constant Field Values
Constructor Detail

UploadToStreamCmdImpl

public UploadToStreamCmdImpl()
Method Detail

getAttachmentStream

public java.io.InputStream getAttachmentStream()
Gets the uploaded attachment Stream
Specified by:
getAttachmentStream in interface UploadToStreamCmd
Returns:
- attachmentStream the uploaded file stream

setErrorURL

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

setRefCmd

public void setRefCmd(java.lang.String name)
Sets the refcmd of the the command which extends this command. Note that the base refcmd should match the command attribute in the attachment configurations in instance.xml file and it should be the commandName in the command context, ie. the URL command that extends the UploadToStreamCmd
Parameters:
name - reference command name

setUrl

public void setUrl(java.lang.String returnURL)
Sets the Url to be returned when upload is completed .
Parameters:
returnURL - the url to be returned when upload is complete

getStoreName

protected java.lang.String getStoreName()
Gets the storename.
Returns:
storeName the store that user logs in when execute this command

getFileName

public java.lang.String getFileName()
Gets the filename of the uploaded attachment
Specified by:
getFileName in interface UploadToStreamCmd
Returns:
filename the filename of the attachment file

getUrl

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

getErrorURL

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

getFileSize

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

getAttachmentOwner

public long getAttachmentOwner()
Gets the owner_id of the attachment creator
Specified by:
getAttachmentOwner in interface UploadToStreamCmd
Returns:
owner id the member id of the user who uploads the attachment

setRootPath

public void setRootPath(java.lang.String path)
Sets the rootPath of where the file should be uploaded .
Parameters:
path - the rootpath of where the file is uploaded. The default value is $wcsstore

getRootPath

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

getContentType

protected java.lang.String getContentType()
Gets the contentType of the uploaded file *
Returns:
String content type

getFileName_NoExt

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

getFileExtension

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

setRequestProperties

public void setRequestProperties(TypedProperty reqParms)
                          throws ECException
Description copied from interface: ControllerCommand
Sets the request properties. The WebController calls this method before invoking the execute method in this command to set the request properties for this command. It is the responsibility of the implementer of the ControllerCommand to extract the required input parameters from the request properties and perform parameter checking.
Specified by:
setRequestProperties in interface ControllerCommand
Overrides:
setRequestProperties in class ControllerCommandImpl
Parameters:
reqParms - request properties
Throws:
ECException - Raised with message ECMessage._ERR_CMD_INVALID_PARAM when an unexpected error occurs when processing the command parameters Raised with message ECMessage._ERR_REMOTE_EXCEPTION when an remote error occurs Raised with message ECMessage._ERR_UPLOAD_REFCMD_MISSING_CONFIG_PARAMS when there is no configuration for the refcmd in the instance file
See Also:
ContollerCommand#setRequestProperties()

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

performExecute

public void performExecute()
                    throws ECException
This method contains the main business logic of this command. It will upload the file from client into input stream
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
ECException
See Also:
ControllerComand#performExecute