com.ibm.commerce.command
Class AbstractECCommand

java.lang.Object
  |
  +--com.ibm.commerce.command.AbstractECCommand

public abstract class AbstractECCommand
extends java.lang.Object

This is the abstract base class for all commerce ECCommands


Field Summary
protected  CommandContext commandContext
           
 
Constructor Summary
AbstractECCommand()
          Constructor of AbstractECCommand
 
Method Summary
 boolean accessControlCheck()
          Performs command level access control check for this command.
 void checkIsAllowed(java.lang.Object resource, java.lang.String action)
          Checks if user can perform action on a resource.
protected  void checkParameters()
          Deprecated. Replaced by validateParameters()
 void checkResourcePermission()
          Performs resource level access control check.
 void createCommandExecutionEvent(CommandExecutionTrigger trigger)
          Creates a command execution event.
 void execute()
          This method is part of the command framework.
 void finalize()
          Final clean up of resources.
 boolean getAccCheck()
          Gets the access control flag.
  CommandContext getCommandContext()
          Gets the command context associated with this command.
 java.lang.String getCommandIfName()
          Gets the command interface name.
 java.lang.String getCommandName()
          Gets the name of the originating command.
 java.lang.Integer getCommandStoreId()
          Gets the store Id used to create this command.
 TypedProperty getDefaultProperties()
          Gets the default properties associated with this command.
 AccessVector getResources()
          Gets the access vector accessed by this command.
 java.lang.Integer getStoreId()
          Gets the store Id associated with this command.
 UserAccessBean getUser()
          Gets the userAccessBean associated with the user.
 java.lang.Long getUserId()
          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 frame work This is where client side parameter checking is performed before the execution of the command.
 void performExecute()
          Performs the business logic for this command.
 void reset()
          This method is called after a command has been executed to reset its states variables.
 void setAccCheck(boolean newValue)
          Set the access control flag for this command.
 void setCommandContext( CommandContext aCommandContext)
          Sets the command context associated with this command.
 void setCommandIfName(java.lang.String name)
          Sets the command interface name.
 void setCommandStoreId(java.lang.Integer storeId)
          Sets the store Id used to create this command.
 void setDefaultProperties(com.ibm.commerce.datatype.TypedProperty value)
          Sets default properties associated with this ECCommand.
 void validateParameters()
          Performs server side parameter checking.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

commandContext

protected CommandContext commandContext
Constructor Detail

AbstractECCommand

public AbstractECCommand()
Constructor of AbstractECCommand
Method Detail

accessControlCheck

public boolean accessControlCheck()
                           throws ECException
Performs command level access control check for this command.
Returns:
true if user has authority and false if user has no authority
Throws:
ECException - - ECApplicationException indicating an _ERR_USER_AUTHORITY error

checkIsAllowed

public void checkIsAllowed(java.lang.Object resource,
                           java.lang.String action)
                    throws ECException
Checks if user can perform action on a resource.
Parameters:
resource - resource to be acted on
action - action to be performed on the resource
Throws:
ECException - - ECApplicationException indicating an _ERR_USER_AUTHORITY error

checkParameters

protected void checkParameters()
                        throws ECException
Deprecated. Replaced by validateParameters()
Performs server side parameter checking. This method is replaced by the validateParameters() method Command writers should NOT implement this method but implement validateParameters() instead. The default implementation of checkParameters is just a no op.
Throws:
ECException.
ECException

checkResourcePermission

public void checkResourcePermission()
                             throws ECException
Performs resource level access control check. 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.
Throws:
ECException - - _ERR_USER_AUTHORITY if user has no 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.
Throws:
ECException

getAccCheck

public boolean getAccCheck()
Gets the access control flag.
Returns:
true if access control check is required for this command and false if access control check is not required for this command

getCommandContext

public final CommandContext getCommandContext()
Gets the command context associated with this command. The command context has to be set before we execute any command.
Returns:
command context object.

getCommandIfName

public final java.lang.String getCommandIfName()
Gets the command interface name.
Returns:
comamnd interface name

getCommandName

public final java.lang.String getCommandName()
Gets the name of the originating command. This is the url name defined in the URLREG.
Returns:
comamnd name

getDefaultProperties

public final TypedProperty getDefaultProperties()
Gets the default properties associated with this command.
Returns:
default properties

getResources

public AccessVector getResources()
                          throws ECException
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 responsibilities of the command writer to return the protectable primary resource(s) and the corresponding actions accessed by this command.
Returns:
vector of resource action pairs
ECException

getStoreId

public final java.lang.Integer getStoreId()
Gets the store Id associated with this command.
Returns:
the store Id.

getCommandStoreId

public final java.lang.Integer getCommandStoreId()
Gets the store Id used to create this command. This is used internally by the command framework.
Returns:
the command store Id.

setCommandStoreId

public final void setCommandStoreId(java.lang.Integer storeId)
Sets the store Id used to create this command. This is used internally by the command factory when creating the command
Parameters:
storeId - the command store Id.

getUser

public final UserAccessBean getUser()
                             throws com.ibm.commerce.exception.ECSystemException
Gets the userAccessBean associated with the user.
Returns:
user access bean
Throws:
com.ibm.commerce.exception.ECSystemException

getUserId

public final java.lang.Long getUserId()
Gets the user Id for the user associated with this command from the command context.
Returns:
the user Id.

isReadyToCallExecute

public boolean isReadyToCallExecute()
This method is called by the Targetable Command frame work This is where client side parameter checking is performed before the execution of the command. The default implementation is to return true.
Returns:
boolean - true if we can execute the command false if we canot execute the command

performExecute

public void performExecute()
                    throws ECException
Performs the business logic for this command. This method should be overwritten by all command writers. Command writers.
Throws:
ECException.
ECException

reset

public void reset()
This method is called after a command has been executed to reset its states variables. After the call to reset, we should be able to execute the command again.

setAccCheck

public void setAccCheck(boolean newValue)
Set the access control flag for this command.
Parameters:
newValue - boolean - true if access check is required - false if access check is not required

setCommandContext

public final void setCommandContext(CommandContext aCommandContext)
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 invokes by a caller. Command writers has to set the command context for any subsequent commands it instantiate and execute. If one command needs to calls another command with a different set of parameters that will affect the command context such as the user Id or store then the command writer should make a clone of the original command context and then perform a setRequestProperties() method on the clone with the new sets of requestProperties

setCommandIfName

public final void setCommandIfName(java.lang.String name)
Sets the command interface name. This method is called by the command factory at command creation time.
Parameters:
name - the command interface name.

setDefaultProperties

public final void setDefaultProperties(com.ibm.commerce.datatype.TypedProperty value)
Sets default properties associated with this ECCommand. Default properties are defined in the URLREG for controller commands and is defined in the VIEWREG for view commands. This method is called by the CommandFactory during command creation to set the default properties for this command.
Parameters:
value - properties value

validateParameters

public void validateParameters()
                        throws ECException
Performs server side parameter checking. This method replaces the checkParameters() method in a previous version of the code.
Throws:
ECException.
ECException

finalize

public void finalize()
Final clean up of resources.
Overrides:
finalize in class java.lang.Object

createCommandExecutionEvent

public void createCommandExecutionEvent(CommandExecutionTrigger trigger)
                                 throws ECException
Creates a command execution event.
Parameters:
trigger - command execution trigger
Throws:
ECException