com.ibm.commerce.command

Class TempUploadCmdImpl

  • All Implemented Interfaces:
    AccCommand, ControllerCommand, ECCommand, ECTargetableCommand, TempUploadCmd, Protectable, com.ibm.websphere.cache.Sizeable, com.ibm.websphere.command.CacheableCommand, com.ibm.websphere.command.Command, com.ibm.websphere.command.CommandCaller, com.ibm.websphere.command.TargetableCommand, java.io.Serializable
    Direct Known Subclasses:
    WebAssetsUploadCmdImpl


    public class TempUploadCmdImpl
    extends ControllerCommandImpl
    implements TempUploadCmd

    This class will upload file to a file system with a unique generated filename. Note that this is not registered in the URL configuration or the command configuration. This class is not intended to be used directly. It should be extended by other commands.

    The file path to be uploaded is $wcsstore\storename\filepath. $wcsstore is defined in instance configuration file. storename is based on the store_id retrieved from the command context, that is, the store that you logon to. filepath is user input.

    See Also:
    Serialized Form
    • Field Detail

      • COPYRIGHT

        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()
        This method gets the attachmenturl of the uploaded file.
        Specified by:
        getAttachmentURL in interface TempUploadCmd
        Returns:
        A String that represents the attachmenturl.
      • setErrorURL

        public void setErrorURL(java.lang.String errorURL)
        This method sets the errorURL to be forwarded when an error occurs during upload.
        Parameters:
        A - String that represents the errorURL.
      • setFilePath

        public void setFilePath(java.lang.String path)
        This method sets the subdirectories (after the predefined path) of the attachment to be uploaded. The predefined path is rootpath\storename. For example, if xml file rootpath= drive:\WebSphere\AppServer\InstalledApps\wcsstores.war\xml else rootpath=drive:\WebSphere\AppServer\InstalledApps\wcsstores.war\
        Parameters:
        A - String that represents the file path.
      • getFilePath

        public java.lang.String getFilePath()
        This method gets the file path (after the predefined path) of the attachment to be uploaded.
        Returns:
        A String that represents the file path.
      • setRefCmd

        public void setRefCmd(java.lang.String name)
        This method sets the refcmd of the command which extends the base TempUpload. The refcmd should match the command name in attachment configuration in the <instance_name>.xml file. It should also be the commandName in the command context, that is, the URL command that extends tempUploadCmd.
        Parameters:
        name - A String that represents the component command name.
      • setRename

        public void setRename(java.lang.String name)
        This method sets the new name that the user wishes to assign to the uploaded file (the "rename").
        Parameters:
        name - A String that represents the rename.
      • setUrl

        public void setUrl(java.lang.String returnURL)
        This method sets the URL to be returned/redirected when the upload is completed.
        Parameters:
        name - A String that represents the returnURL.
      • getRename

        public java.lang.String getRename()
        This method gets the new name that the user wishes to assign to the uploaded file (the "rename").
        Returns:
        A String that represents the returnURL.
      • setRootPath

        public void setRootPath(java.lang.String path)
        This method sets the rootPath where the file should be uploaded.
        Parameters:
        path - A String that represents the rootpath.
      • getRootPath

        public java.lang.String getRootPath()
        This method gets the rootPath where the file should be uploaded.
        Returns:
        A String that represents the rootpath.
      • getStoreName

        public java.lang.String getStoreName()
        This method gets the storeName from the command context.
        Returns:
        A String that represents the storeName.
      • getFileName

        public java.lang.String getFileName()
        This method gets the fileName of the uploaded file.
        Specified by:
        getFileName in interface TempUploadCmd
        Returns:
        A String that represents the fileName.
      • getUrl

        public java.lang.String getUrl()
        This method gets the URL to be returned when the upload is completed.
        Specified by:
        getUrl in interface TempUploadCmd
        Returns:
        A String that represents the URL.
      • getErrorURL

        public java.lang.String getErrorURL()
        This method gets the errorURL where the user should be redirected when an error occurs during upload.
        Returns:
        A String that represents the errorURL.
      • getFileSize

        public long getFileSize()
        This method gets the filesize of the uploaded file.
        Specified by:
        getFileSize in interface TempUploadCmd
        Returns:
        A long value that represents the size of the uploaded file.
      • getAttachmentOwner

        public long getAttachmentOwner()
        This method gets the creator of the uploaded attachment, that is, the user who logs on to the store.
        Specified by:
        getAttachmentOwner in interface TempUploadCmd
        Returns:
        A long value that represents the owner_id of the user who uploads the attachment.
      • setRequestProperties

        public void setRequestProperties(TypedProperty reqParms)
                                  throws ECException
        This method sets the request properties. Some examples of request properties are refcmd, filepath, rename, filename, and errorURL. This method gets the user_id and store_id from the command context It gets the configurable parameters maxuploadsize, viruscheck and the supportedfile extension from <instance_name>.xml based on refcmd.
        Specified by:
        setRequestProperties in interface ControllerCommand
        Overrides:
        setRequestProperties in class ControllerCommandImpl
        Parameters:
        reqParms - The request parameters.
        Throws:
        ECException
        See Also:
        ControllerComand#performExecute
      • validateParameters

        public void validateParameters()
                                throws ECException
        This method 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 - Thrown with the message ECMessage._ERR_UPLOAD_MISSING_REFCMD when refcmd is missing from the <instance_name>.xml file attachment configuration section. Thrown with the message ECMessage._ERR_UPLOAD_FILECONTENTTYPE_NOTALLOWED when the contenttype of the upload file does not match the file extension. Thrown with the message ECMessage._ERR_UPLOAD_FILETYPE_NOTALLOWED when the file type is not contained in supportedfileextension as specified in the attachment configuration. Thrown with the message ECMessage._ERR_UPLOAD_FILESIZE_TOOBIG when the filesize exceeds the maximum allowable size in the attachment configuration section of the <instance_name>.xml file.
      • constructFileString

        public java.lang.String constructFileString()
        This method constructs the attachmenturl.
        Returns:
        A String that represents the attachmenturl of the uploaded file.
      • performExecute

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