com.ibm.commerce.contract.commands

Class ContractSaveCmdImpl

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


    public class ContractSaveCmdImpl
    extends TradingAgreementImportBaseCmdImpl
    implements ContractSaveCmd
    This is the default implementation of the ContractSaveCmd controller command.

    Input parameters:

    Name Description
    ContractId The id of the contract. Mandatory.
    ContractState The state of the contract. Optional.
    CurrentContractState The current state of the contract. Sets this parameter before executing isInRightStateToUpdate()
    LanguageId The language id. Optional.
    LastUpdatedTime The last update time of the contract. Optional.
    request properties the request properties. Possible values include redirecturl, XMLFile, xml, XSDValidation, LastUpdatedTime. Optional.
    XML the input xml string. Mandatory.
    XSDValidation The XSD validation flag. If the flag is set to true, the xml parser will validate the xml instance against the specified XSD file. Mandatory.

    Behaviour:

    Add a new contract or update an existing one which is in Draft state (WebSphere Commerce Enterprise only).

    Task commands called:

    CreateXSDContractCmd, UpdateXSDContractCmd If it updates an existing contract, the UpdateXSDContractCmd command will be called. If it adds a new contract, the CreateXSDContractCmd command will be called.

    AccessBeans called:

    ContractAccessBean, AccountAccessBean, ParticipantAccessBean.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      java.lang.Integer getContractState()
      Returns the contract state.
      com.ibm.commerce.datatype.TypedProperty getViewInputProperties()
      This method is called by the web controller to retrieve the request properties set by the setRequestProperties() method.
      boolean isInRightStateToUpdate()
      Checks if the contract is in right state for updating action.
      boolean isUpdate()
      Returns if the action of this command based on the information inside the xml string.
      void performExecute()
      Executes the business logic of this command implementation.
      void setContractId(java.lang.Long contractId)
      Sets the contract id parameter.
      void setContractState(java.lang.Integer contractState)
      Sets the contract state parameter.
      void setCurrentContractState(java.lang.Integer curContractState)
      Sets the current contract state parameter.
      void setLanguageId(java.lang.Integer langId)
      Sets the language id parameter.
      void setLastUpdatedTime(java.lang.String lastUpdatedTime)
      Sets the last update time of the contract.
      void setRequestProperties(com.ibm.commerce.datatype.TypedProperty aRequestProperties)
      Retrieves input parameters from the request properties.
      void setXML(java.lang.String xmlString)
      Sets the input xml string.
      void setXSDValidation(boolean bValidation)
      Sets the XSD validation flag.
      void validateParameters()
      The method checks if the information provided in contract Element object is valid.
      • 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, 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, 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 name of this class
        See Also:
        Constant Field Values
      • COPYRIGHT

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

      • ContractSaveCmdImpl

        public ContractSaveCmdImpl()
    • Method Detail

      • getContractState

        public java.lang.Integer getContractState()
        Returns the contract state.
        Returns:
        the contract state.
      • getViewInputProperties

        public com.ibm.commerce.datatype.TypedProperty getViewInputProperties()
        This method is called by the web controller to retrieve the request properties set by the setRequestProperties() method. The tools need to override this method because otherwise the properties passed into the controller command would be then passed onto the view command. This is unnecessary for the tools and actually will break us when using the ReDirectView command. Because the URL to re-direct to cannot be more than 500 chars. The xml parameter alone passed into the controller command is longer than this. And therefore without overriding this method we couldn't re-direct to the view command.
        Specified by:
        getViewInputProperties in interface com.ibm.commerce.command.ControllerCommand
        Overrides:
        getViewInputProperties in class com.ibm.commerce.command.ControllerCommandImpl
        Returns:
        com.ibm.commerce.datatype.TypeProperty
      • isInRightStateToUpdate

        public boolean isInRightStateToUpdate()
        Checks if the contract is in right state for updating action.
        Returns:
        a boolean value. true: the contract is in right state to update. false: the contract is not in right state.
      • isUpdate

        public boolean isUpdate()
        Returns if the action of this command based on the information inside the xml string.
        Returns:
        a boolean value represents the action of the command. true: create; false: update
      • performExecute

        public void performExecute()
                            throws com.ibm.commerce.exception.ECException
        Executes the business logic of this command implementation.
        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_CONTRACT_SAVE when an error occurred.
        See Also:
        CreateXSDContractCmdImpl.performExecute(), UpdateXSDContractCmdImpl.performExecute(), AbstractECTargetableCommand.performExecute()
      • setContractId

        public void setContractId(java.lang.Long contractId)
        Sets the contract id parameter.
        Parameters:
        contractId - the id of the contract
      • setContractState

        public void setContractState(java.lang.Integer contractState)
        Sets the contract state parameter.
        Parameters:
        contractState - the state of the contract
      • setCurrentContractState

        public void setCurrentContractState(java.lang.Integer curContractState)
        Sets the current contract state parameter.
        Parameters:
        curContractState - the current state of the contract
      • setLanguageId

        public void setLanguageId(java.lang.Integer langId)
        Sets the language id parameter.
        Parameters:
        langId - the language id
      • setLastUpdatedTime

        public void setLastUpdatedTime(java.lang.String lastUpdatedTime)
        Sets the last update time of the contract.
        Specified by:
        setLastUpdatedTime in interface ContractSaveCmd
        Parameters:
        lastUpdatedTime - the last update time string
      • setRequestProperties

        public void setRequestProperties(com.ibm.commerce.datatype.TypedProperty aRequestProperties)
                                  throws com.ibm.commerce.exception.ECApplicationException
        Retrieves input parameters from the request properties.
        Specified by:
        setRequestProperties in interface com.ibm.commerce.command.ControllerCommand
        Overrides:
        setRequestProperties in class com.ibm.commerce.command.ControllerCommandImpl
        Parameters:
        aRequestProperties - An TypedProperty object contains the input parameters.
        Throws:
        com.ibm.commerce.exception.ECApplicationException - Raised with message _ERR_MISSING_CMD_PARAMETER when the input xml string is missed.
      • setXML

        public void setXML(java.lang.String xmlString)
        Sets the input xml string.
        Specified by:
        setXML in interface ContractSaveCmd
        Parameters:
        xmlString - the input xml string.
      • setXSDValidation

        public void setXSDValidation(boolean bValidation)
        Sets the XSD validation flag. If the flag is set to true, the xml parser will validate the xml instance against the specified XSD file.
        Specified by:
        setXSDValidation in interface ContractSaveCmd
        Parameters:
        bValidation - the validation flag, true: validate, false: do not validate.
      • validateParameters

        public void validateParameters()
                                throws com.ibm.commerce.exception.ECException
        The method checks if the information provided in contract Element object is valid.
        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_WRONG_CONTRACT_STATE if the state of the contract is not in Draft state. Raised with message _ERR_WRONG_ACCOUNT_OWNER_INFO when the member id cannot be found. It is based on the specified account owner, if the contract refers to an account. Raised with message _ERR_ACCOUNT_DOES_NOT_EXIST when the account cannot be found based the provided account name and owner information. If the contract refers to an account, it occurs. Raised with message EC_ERR_NO_AUTH_REF_ANOTHER_TRADING if the referred to contract is not a Referral or Hosting contract. And if the contract owner is not as a Referral/Reseller participant in the referred Referral/Hosting contract, it occurs. Raised with message _ERR_DUPLICATED_CONTRACT_NAME if there is an existing contract with the same name, origin, and state in the database and the action is created. Raised with message _ERR_WRONG_CONTRACT_OWNER_MEMBER_INFO if the contract owner id cannot be retrieved based on the contract owner information specified in the xml string.
        See Also:
        AbstractECTargetableCommand.validateParameters()