com.ibm.commerce.command

Class AbstractECCommand

  • java.lang.Object
    • com.ibm.commerce.command.AbstractECCommand
  • All Implemented Interfaces:
    ECCommand, com.ibm.websphere.command.Command, java.io.Serializable
    Direct Known Subclasses:
    AbstractViewCommand


    public abstract class AbstractECCommand
    extends java.lang.Object
    implements ECCommand
    This is the abstract base class for all commerce ECCommand objects.
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from interface com.ibm.websphere.command.Command

        serialVersionUID
    • Constructor Summary

      Constructors 
      Constructor and Description
      AbstractECCommand()
      This is the default constructor for this class.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean accessControlCheck()
      This method performs a command level access control check for this command.
      void checkIsAllowed(java.lang.Object resource, java.lang.String action)
      This method determines whether a user can perform a specified action on a certain resource.
      void checkResourcePermission()
      This method performs resource level access control checking.
      void createCommandExecutionEvent(com.ibm.commerce.command.event.CommandExecutionTrigger trigger)
      This method creates a command execution event.
      void execute()
      This method is part of the command framework.
      boolean getAccCheck()
      This method checks to see if an access control check is required for this command.
      CommandContext getCommandContext()
      This method gets the command context associated with this command.
      java.lang.String getCommandIfName()
      This method gets the command interface name.
      java.lang.String getCommandName()
      This method gets the name of the originating command.
      java.lang.Integer getCommandStoreId()
      This method gets the store id used to create this command.
      TypedProperty getDefaultProperties()
      This method gets the default properties associated with this command.
      java.util.Map getExceptionInvokeParameters(java.lang.String event)
      This method returns the attributes for a particular event type when the command executed throws an exception.
      java.util.Map getPostInvokeParameters(java.lang.String event)
      This method returns the attributes for a particular event type after the command is executed.
      java.util.Map getPreInvokeParameters(java.lang.String event)
      This method returns the attributes for a particular event type before the command is executed.
      AccessVector getResources()
      This method gets the access vector accessed by this command.
      java.lang.Integer getStoreId()
      This method gets the store id associated with this command.
      UserAccessBean getUser()
      This method gets the UserAccessBean object associated with the user.
      java.lang.Long getUserId()
      This method gets the user id for the user associated with this command from the command context.
      boolean isReadyToCallExecute()
      This method is called by the targetable command framework.
      void performExecute()
      This method performs the business logic for this command.
      void reset()
      This method is called after a command has been executed.
      void setAccCheck(boolean newValue)
      This method sets the access control flag for this command.
      void setCommandContext(CommandContext aCommandContext)
      This method sets the command context associated with this command.
      void setCommandIfName(java.lang.String name)
      This method sets the command interface name.
      void setCommandStoreId(java.lang.Integer storeId)
      This method sets the store id used to create this command.
      void setDefaultProperties(TypedProperty value)
      This method sets default properties associated with this ECCommand.
      static java.lang.String setForUserId(CommandContext currentContext)
      a utility to set forUserId
      static java.lang.String setUserId(CommandContext currentContext)
      a utility to set userId
      void validateParameters()
      This method performs server side parameter checking.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AbstractECCommand

        public AbstractECCommand()
        This is the default constructor for this class. It calls the constructor from the superclass.
    • Method Detail

      • accessControlCheck

        public boolean accessControlCheck()
                                   throws ECException
        This method performs a command level access control check for this command.
        Returns:
        This method returns true if the user has authority and false if user has no authority.
        Throws:
        ECException - An ECApplicationException is thrown when an _ERR_USER_AUTHORITY error occurs.
      • checkIsAllowed

        public void checkIsAllowed(java.lang.Object resource,
                                   java.lang.String action)
                            throws ECException
        This method determines whether a user can perform a specified action on a certain resource.
        Specified by:
        checkIsAllowed in interface ECCommand
        Parameters:
        resource - This is the resource to be acted on.
        action - This is the action to be performed on the resource.
        Throws:
        ECException - An ECApplicationException is thrown when an _ERR_USER_AUTHORITY error occurs.
      • checkResourcePermission

        public void checkResourcePermission()
                                     throws ECException
        This method performs resource level access control checking. The default implementation calls the AccManager to perform resource level access control checking based on the command interface name and the AccessVector returned by the getResources() method. This method will throw an ECApplicationException with message _ERR_USER_AUTHORITY if the user has no authority to perform the operation on the resource.
        Specified by:
        checkResourcePermission in interface ECCommand
        Throws:
        ECException - This is thrown with the message _ERR_USER_AUTHORITY if user does not have permission to perform the operation on the resource.
      • execute

        public void execute()
                     throws ECException
        This method is part of the command framework. Command writers should not touch this method. An ECException will be thrown if there are any errors detected during the command execution.
        Specified by:
        execute in interface ECCommand
        Specified by:
        execute in interface com.ibm.websphere.command.Command
        Throws:
        ECException - This is thrown if there are any errors detected during the command execution.
      • setUserId

        public static java.lang.String setUserId(CommandContext currentContext)
        a utility to set userId
        Parameters:
        currentContext - the current context that a userId is in
        Returns:
        userId
      • setForUserId

        public static java.lang.String setForUserId(CommandContext currentContext)
                                             throws ECException
        a utility to set forUserId
        Parameters:
        currentContext - the current context that a forUserid is in
        Returns:
        forUserId
        Throws:
        ECException
      • getAccCheck

        public boolean getAccCheck()
        This method checks to see if an access control check is required for this command.
        Specified by:
        getAccCheck in interface ECCommand
        Returns:
        This method returns true if an access control check is required for this command, and false otherwise.
      • getCommandContext

        public final CommandContext getCommandContext()
        This method gets the command context associated with this command. The command context has to be set before any commands are executed.
        Specified by:
        getCommandContext in interface ECCommand
        Returns:
        This method returns a CommandContext object.
      • getCommandIfName

        public final java.lang.String getCommandIfName()
        This method gets the command interface name.
        Specified by:
        getCommandIfName in interface ECCommand
        Returns:
        This method returns the command interface name.
      • getCommandName

        public final java.lang.String getCommandName()
        This method gets the name of the originating command. This is the URL name defined in the URL configuration.
        Specified by:
        getCommandName in interface ECCommand
        Returns:
        This method returns the command name.
      • getDefaultProperties

        public final TypedProperty getDefaultProperties()
        This method gets the default properties associated with this command.
        Specified by:
        getDefaultProperties in interface ECCommand
        Returns:
        This method returns the default properties.
      • getResources

        public AccessVector getResources()
                                  throws ECException
        This method gets the access vector accessed by this command. The default implementation returns null indicating that no protectable resource is accessed by this command. It is the responsibility of the command writer to return the protectable primary resource(s) and the corresponding actions accessed by this command.
        Specified by:
        getResources in interface ECCommand
        Returns:
        This method returns an AccessVector object of resource/action pairs.
        Throws:
        ECException
      • getStoreId

        public final java.lang.Integer getStoreId()
        This method gets the store id associated with this command.
        Specified by:
        getStoreId in interface ECCommand
        Returns:
        This method returns the store id.
      • getCommandStoreId

        public final java.lang.Integer getCommandStoreId()
        This method gets the store id used to create this command. This method is used internally by the command framework.
        Specified by:
        getCommandStoreId in interface ECCommand
        Returns:
        This method returns the command store id.
      • setCommandStoreId

        public final void setCommandStoreId(java.lang.Integer storeId)
        This method sets the store id used to create this command. This is used internally by the command factory when creating the command.
        Specified by:
        setCommandStoreId in interface ECCommand
        Parameters:
        storeId - This is the command store id.
      • getUserId

        public final java.lang.Long getUserId()
        This method gets the user id for the user associated with this command from the command context.
        Specified by:
        getUserId in interface ECCommand
        Returns:
        This method returns the user id.
      • isReadyToCallExecute

        public boolean isReadyToCallExecute()
        This method is called by the targetable command framework. This is where client side parameter checking is performed (before the execution of the command). The default implementation is to return true.
        Specified by:
        isReadyToCallExecute in interface com.ibm.websphere.command.Command
        Returns:
        This method returns a boolean value; true if we can execute the command and false otherwise. This default implementation will always return true.
      • performExecute

        public void performExecute()
                            throws ECException
        This method performs the business logic for this command. This method should be overwritten by all command writers.
        Specified by:
        performExecute in interface ECCommand
        Throws:
        ECException
      • reset

        public void reset()
        This method is called after a command has been executed. It is used to reset its states variables. After the call to reset, the command should be able to be executed again.
        Specified by:
        reset in interface com.ibm.websphere.command.Command
      • setAccCheck

        public void setAccCheck(boolean newValue)
        This method sets the access control flag for this command.
        Specified by:
        setAccCheck in interface ECCommand
        Parameters:
        newValue - This is a boolean value; true if an access check is required, and false otherwise.
      • setCommandContext

        public final void setCommandContext(CommandContext aCommandContext)
        This method sets the command context associated with this command. It is the responsibility of the caller of the command to call this method to set up the command context before invoking the command. The WebController will set the command context for the top level controller command invoked by a caller. Command writers have to set the command context for any subsequent commands to be instantiated and executed. It is possible that one command will need to call another command with a different set of parameters that will affect the command context. In this case, the command writer should make a clone of the original command context. The command writer should then call the setRequestProperties() method on the clone with the new sets of RequestProperties. Examples of parameters that affect the command context are the user id and store id.
        Specified by:
        setCommandContext in interface ECCommand
        Parameters:
        aCommandContext - This is a CommandContext object.
      • setCommandIfName

        public final void setCommandIfName(java.lang.String name)
        This method sets the command interface name. This method is called by the command factory when the command is created.
        Specified by:
        setCommandIfName in interface ECCommand
        Parameters:
        name - This is the command interface name.
      • setDefaultProperties

        public final void setDefaultProperties(TypedProperty value)
        This method sets default properties associated with this ECCommand. Default properties are defined in the URL configuration. This method is called by the CommandFactory object during command creation to set the default properties for this command.
        Specified by:
        setDefaultProperties in interface ECCommand
        Parameters:
        value - This is a TypedProperty object.
      • validateParameters

        public void validateParameters()
                                throws ECException
        This method performs server side parameter checking. This method replaces the checkParameters() method from version 5.1.
        Specified by:
        validateParameters in interface ECCommand
        Throws:
        ECException
      • createCommandExecutionEvent

        public void createCommandExecutionEvent(com.ibm.commerce.command.event.CommandExecutionTrigger trigger)
                                         throws ECException
        This method creates a command execution event.
        Specified by:
        createCommandExecutionEvent in interface ECCommand
        Parameters:
        trigger - This is a command execution trigger.
        Throws:
        ECException
      • getPreInvokeParameters

        public java.util.Map getPreInvokeParameters(java.lang.String event)
        This method returns the attributes for a particular event type before the command is executed.
        Specified by:
        getPreInvokeParameters in interface ECCommand
        Parameters:
        event - This is the event type.
        Returns:
        This method returns the attributes associated with the event type.
      • getPostInvokeParameters

        public java.util.Map getPostInvokeParameters(java.lang.String event)
        This method returns the attributes for a particular event type after the command is executed.
        Specified by:
        getPostInvokeParameters in interface ECCommand
        Parameters:
        event - This is the event type.
        Returns:
        This method returns the attributes associated with the event type.
      • getExceptionInvokeParameters

        public java.util.Map getExceptionInvokeParameters(java.lang.String event)
        This method returns the attributes for a particular event type when the command executed throws an exception.
        Specified by:
        getExceptionInvokeParameters in interface ECCommand
        Parameters:
        event - This is the event type.
        Returns:
        This method returns the attributes associated with the event type.