com.ibm.commerce.contract.commands

Class ContractImportApprovedVersionCmdImpl

  • java.lang.Object
    • com.ibm.websphere.command.CacheableCommandImpl
  • All Implemented Interfaces:
    com.ibm.commerce.command.AccCommand, com.ibm.commerce.command.ControllerCommand, com.ibm.commerce.command.ECCommand, com.ibm.commerce.command.ECTargetableCommand, ContractImportApprovedVersionCmd, com.ibm.commerce.security.Protectable, com.ibm.websphere.command.CacheableCommand, com.ibm.websphere.command.Command


    public class ContractImportApprovedVersionCmdImpl
    extends TradingAgreementImportBaseCmdImpl
    implements ContractImportApprovedVersionCmd
    This is the default implementation of the ContractImportApprovedVersionCmd controller command.

    Input parameters:

    Name Description
    fileName The file name of the importing xml file. It is mandatory.
    URL The url parameter. It is mandatory.
    path The xml entity path. It is mandatory.
    targetStoreId The target store ID for deploying contract. It is optional.
    xsd The flag indicates if a xml instance file is based on XSD or not. It is optional.
    validate The flag indicates if validating an importing xml file against a xml schema. It is optional.
    synchronousDeployment The synchronous deployment parameter. It is optional.
    contractList The contract list file name parameter. It is optional.

    Output parameters:

    None.

    Behaviour:

    Imports a contract from a specified xml file (WebSphere Commerce Enterprise only). The state of the contract in the xml file has to be either Approved or Active.

    Task command called:

    Access Beans used:

    ContractAccessBean, AccountAccessBean, UserAccessBean, OrganizationAccessBean, MemberGroupAccessBean, ParticipantAccessBean, and the AccessBeans are used in the default implementation of the called commands.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Integer getContractState()
      Returns the state of the new created contract.
      java.lang.String getUrl()
      Gets the redirection URL to be called when the command completes successfully.
      static java.lang.String importContract(java.lang.String fileName, java.lang.Integer storeId, com.ibm.commerce.command.CommandContext cmdCxt)
      Imports a contract.
      void performExecute()
      Executes the business logic of this command implementation.
      void setContractListFileName(boolean isContractListFlag)
      Sets the contractList flag to indicate the file is a list of contract files to import.
      void setContractXML(java.io.InputStream contractXML)
      Sets the contract xml instance.
      void setContractXMLFileName(java.lang.String contractFileName)
      Sets the contract xml file name.
      void setRequestProperties(com.ibm.commerce.datatype.TypedProperty aRequestProperties)
      Sets the request properties of this command implementation.
      void setRootElement(org.w3c.dom.Element rootDocElm)
      Sets the root Element of the contract xml file.
      void setStoreId(java.lang.Integer storeId)
      Sets the ID of the store which the contract will be deployed to.
      void setSynchronousDeployment(boolean synchronousDeploymentFlag)
      Sets the synchronousDeployment flag to indicate contract should be deployed synchronously.
      void setUrl(java.lang.String astrUrl)
      Sets the redirect url to be called when the command completes successfully.
      void setXMLEntityPath(java.lang.String path)
      Sets the xml entity path.
      void setXSDFlag(boolean xsdFlag)
      Sets the XSD flag to indicate the xml instance file is based on XSD or dtd.
      void validateParameters()
      Extracts and validates the input parameters of this command implementation.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • 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, checkResourcePermission, createCommandExecutionEvent, execute, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getExceptionInvokeParameters, getObjectSize, getPostInvokeParameters, getPreInvokeParameters, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, reset, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
      • 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, getExceptionInvokeParameters, getPostInvokeParameters, getPreInvokeParameters, getResources, getStoreId, getUser, getUserId, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties
      • Methods inherited from interface com.ibm.commerce.security.Protectable

        fulfills, getOwner
    • Field Detail

      • CLASSNAME

        public static final java.lang.String CLASSNAME
        The full name of this class.
        See Also:
        Constant Field Values
      • CONTRACT_LIST

        public static final java.lang.String CONTRACT_LIST
        The contract list file name parameter.
        See Also:
        Constant Field Values
      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        The IBM copyright notice field.
        See Also:
        Constant Field Values
      • SYNCHRONOUS_DEPLOYMENT

        public static final java.lang.String SYNCHRONOUS_DEPLOYMENT
        The synchronous deployment parameter.
        See Also:
        Constant Field Values
    • Constructor Detail

      • ContractImportApprovedVersionCmdImpl

        public ContractImportApprovedVersionCmdImpl()
    • Method Detail

      • getContractState

        public java.lang.Integer getContractState()
        Returns the state of the new created contract.
        Returns:
        the state of the new created contract.
      • getUrl

        public java.lang.String getUrl()
        Gets the redirection URL to be called when the command completes successfully. Reserved for IBM internal use.
        Returns:
        the redirect URL
      • importContract

        public static java.lang.String importContract(java.lang.String fileName,
                                                      java.lang.Integer storeId,
                                                      com.ibm.commerce.command.CommandContext cmdCxt)
                                               throws java.lang.Exception
        Imports a contract.
        Parameters:
        fileName - the contract xml file name
        storeId - the target store id
        cmdCxt - the command contract
        Returns:
        String the contract ID of the newly imported contract
        Throws:
        java.lang.Exception
      • performExecute

        public void performExecute()
                            throws com.ibm.commerce.exception.ECException
        Executes the business logic of this command implementation. Imports the Approved or Active contract based on the information in contract xml file.
        Specified by:
        performExecute in interface com.ibm.commerce.command.ECCommand
        Overrides:
        performExecute in class com.ibm.commerce.command.AbstractECTargetableCommand
        Throws:
        com.ibm.commerce.exception.ECException - Raised with message _ERR_FINDER_EXCEPTION if the FinderException occurred. Raised with message _ERR_REMOTE_EXCEPTION if the RemoteException occurred. Raised with message _ERR_NAMING_EXCEPTION if the NamingException occurred. Raised with message _ERR_CREATE_EXCEPTION if the CreateException occurred. Raised with message _ERR_SQL_EXCEPTION if the SQLException occurred.
        See Also:
        AddContractNLDescriptionCmdImpl#performExecute(), AddStoreNLDescriptionCmdImpl#performExecute(), TradingAgreementImportBaseCmdImpl#saveContract(Element contractElement, boolean actionFlag), ImportDTDContractApprovedVersionCmdImpl#performExecute(), AbstratECTargetableCommand#performExecute()
      • setContractListFileName

        public void setContractListFileName(boolean isContractListFlag)
        Sets the contractList flag to indicate the file is a list of contract files to import.
        Specified by:
        setContractListFileName in interface ContractImportApprovedVersionCmd
        Parameters:
        isContractListFlag - true if the file is a list of contract files to import, false otherwise
      • setContractXML

        public void setContractXML(java.io.InputStream contractXML)
        Sets the contract xml instance.
        Specified by:
        setContractXML in interface ContractImportApprovedVersionCmd
        Parameters:
        contractXML - an InputStream object contains the contract xml instance
      • setContractXMLFileName

        public void setContractXMLFileName(java.lang.String contractFileName)
        Sets the contract xml file name.
        Specified by:
        setContractXMLFileName in interface ContractImportApprovedVersionCmd
        Parameters:
        contractFileName - the name of the contract xml file
      • setRequestProperties

        public void setRequestProperties(com.ibm.commerce.datatype.TypedProperty aRequestProperties)
                                  throws com.ibm.commerce.exception.ECApplicationException
        Sets the request properties of this command implementation.
        Specified by:
        setRequestProperties in interface com.ibm.commerce.command.ControllerCommand
        Overrides:
        setRequestProperties in class com.ibm.commerce.command.ControllerCommandImpl
        Parameters:
        aRequestProperties - the request properties The mandatory name-value pairs are fileName, URL. The optional name-value pairs are XSD, targetStoreId, validate, path. if the XSD parameter is set to true, it means the xml file is based on XSD. Otherwise it is dtd based. The default value for the XSD parameter is false. The validate parameter indicates if the xml parser will validate the xml file against XSD/DTD. true - validate, false - do not validate. The default value of the validate parameter is true. If the importing contract is an Active contract, the targetStoreId is a required parameter. The path parameter indicates the paths of dtd or xml schema files. The default value of the path is specified in the WebSphere Commerce instance xml file.
        Throws:
        com.ibm.commerce.exception.ECApplicationException - Raised with message _ERR_MISSING_CMD_PARAMETER when any one of the required url parameters is missing.
        See Also:
        ControllerCommand#setRequestProperties(TypedProperty)
      • setRootElement

        public void setRootElement(org.w3c.dom.Element rootDocElm)
        Sets the root Element of the contract xml file.
        Specified by:
        setRootElement in interface ContractImportApprovedVersionCmd
        Parameters:
        rootDocElm - the document Element object of the contract xml
      • setStoreId

        public void setStoreId(java.lang.Integer storeId)
        Sets the ID of the store which the contract will be deployed to.
        Specified by:
        setStoreId in interface ContractImportApprovedVersionCmd
        Parameters:
        storeId - the store ID.
      • setSynchronousDeployment

        public void setSynchronousDeployment(boolean synchronousDeploymentFlag)
        Sets the synchronousDeployment flag to indicate contract should be deployed synchronously.
        Specified by:
        setSynchronousDeployment in interface ContractImportApprovedVersionCmd
        Parameters:
        synchronousDeploymentFlag - true for synchronous deployment, false for asynchronous deployment
      • setUrl

        public void setUrl(java.lang.String astrUrl)
        Sets the redirect url to be called when the command completes successfully.
        Specified by:
        setUrl in interface ContractImportApprovedVersionCmd
        Parameters:
        astrUrl - the redirect url string
      • setXMLEntityPath

        public void setXMLEntityPath(java.lang.String path)
        Sets the xml entity path.
        Specified by:
        setXMLEntityPath in interface ContractImportApprovedVersionCmd
        Parameters:
        path - the path where it can find the dtd or xml Schema file(s)
      • validateParameters

        public void validateParameters()
                                throws com.ibm.commerce.exception.ECException
        Extracts and validates the input parameters of this command implementation. This method does the following checks 1. if the file and the XSD file can be found 2. if the xml file is valid (if the validation is set to true) 3. if the contract is in right state for this command. The contract should be either in Approved or Active state
        Specified by:
        validateParameters in interface com.ibm.commerce.command.ECCommand
        Overrides:
        validateParameters in class com.ibm.commerce.command.AbstractECTargetableCommand
        Throws:
        com.ibm.commerce.exception.ECException - Raised with message _ERR_MISSING_CMD_PARAMETER if the targetStoreId parameter was missing from the url for an Active contract. Raised with message _ERR_FILE_NOT_FOUND if the xml file or XSD file cannot be found. Raised with message _ERR_PARSE_XML_FILE if an error occurred when the xml parser parses the xml file. Raised with message _ERR_GENRIC_PARSE_XML_FILE if an IO error occurred. Raised with message _ERR_WRONG_CONTRACT_STATE if the contract is not in Approved or Active state. Raised with message _ERR_MISSING_CONTRACT_NAME if the contract name is empty string in the xml file. Raised with message _ERR_WRONG_ACCOUNT_OWNER_INFO if an error occurred when retrieving the account owner id. Raised with message _ERR_ACCOUNT_DOES_NOT_EXIST if an error occurred when retrieving the account based the account name and account owner id. Raised with message _ERR_WRONG_CONTRACT_OWNER_MEMBER_INFO if an error occurred when retrieving the contract owner id. Raised with message _ERR_DUPLICATED_CONTRACT_NAME if there is a contract existed with the same name, owner, and origin. Raised with message _ERR_CONTRACT_REFERENCE_NUMBER_NOT_REQUIRED if the contract referenceNumber attribute is provided in the xml file for Contract element. Raised with message _ERR_MISSING_XML_INSTANCE_FOR_CONTRACT_IMPORT if there is not any xml instance object for this command. Raised with message _ERR_XML_DOCUMENT_NULL if there is not Document object in the xml instance. Raised with message _ERR_MISSING_CONTRACT_OR_CONTRACT_DESC_ELEMENT if neither of the contract and contract national language description element is in xml instance.
        See Also:
        AbstractECTargetableCommand#validateParameters()