com.ibm.commerce.command

Class UploadToStreamCmdImpl

    • Field Detail

      • COPYRIGHT

        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()
        This method gets the attachment stream from when the upload is completed.
        Specified by:
        getAttachmentStream in interface UploadToStreamCmd
        Returns:
        An InputStream object that represents the attachment upload stream.
      • setErrorURL

        public void setErrorURL(java.lang.String errorURL)
        This method sets the errorURL to be forwarded to when an error occurs during upload.
        Parameters:
        errorURL - The URL to be forwarded to when an error occurs during upload.
      • setRefCmd

        public void setRefCmd(java.lang.String name)
        This method sets the refcmd of the command which extends this command. 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 the UploadToStreamCmd.
        Parameters:
        name - The reference command name.
      • 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.
      • getFileName

        public java.lang.String getFileName()
        This method gets the fileName of the uploaded file.
        Specified by:
        getFileName in interface UploadToStreamCmd
        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 UploadToStreamCmd
        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 UploadToStreamCmd
        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 UploadToStreamCmd
        Returns:
        A long value that represents the owner_id of the user who uploads the attachment.
      • 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.
      • 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 - Thrown with the message ECMessage._ERR_CMD_INVALID_PARAM when an unexpected error occurs when processing the command parameters. Thrown with the message ECMessage._ERR_REMOTE_EXCEPTION when a remote error occurs. Thrown with the message ECMessage._ERR_UPLOAD_REFCMD_MISSING_CONFIG_PARAMS when there is no configuration for the refcmd in the <instance_name>.xml file
        See Also:
        ContollerCommand#setRequestProperties()
      • 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.
      • performExecute

        public void performExecute()
                            throws ECException
        This method contains the main business logic of this command. It will upload the file from the client into the input stream.
        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:
        ControllerComand#performExecute