com.ibm.commerce.command
Class AbstractECCommand

java.lang.Object
  |
  +--com.ibm.commerce.command.AbstractECCommand
All Implemented Interfaces:
ECCommand
Direct Known Subclasses:
AbstractViewCommand, TaskCommandImpl

public abstract class AbstractECCommand
extends java.lang.Object
implements ECCommand

This is the abstract base class for all commerce ECCommands


Field Summary
protected  CommandContext commandContext
           
 
Fields inherited from interface com.ibm.commerce.command.ECCommand
COPYRIGHT, defaultCommandClassName
 
Constructor Summary
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 to see if the current user can perform an action on a resource.
 void checkResourcePermission()
          Performs resource level access control check.
 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.
 TypedProperty getDefaultProperties()
          Returns 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 from the command context.
 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()
          isReadyToCallExecute 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 setDefaultProperties(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()
Method Detail

accessControlCheck

public boolean accessControlCheck()
                           throws ECException
Performs command level access control check for this command.
Returns:
boolean - true if user has authority - 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 to see if the current user can perform an action on a resource. If the user does not have the authority, ECApplicationException will be thrown. If the user does have the authority, the method simply returns. This is called as needed by the command to perform resource-level access control checking in addition to that already done on resoure-action pairs returned by the getResources() method.

Specified by:
checkIsAllowed in interface ECCommand
Parameters:
resource - Object - the resource to be acted on
action - String - action to be performed on the resource
Throws:
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.

Specified by:
checkResourcePermission in interface ECCommand
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.
Specified by:
execute in interface ECCommand
Throws:
ECException -  

finalize

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

getAccCheck

public boolean getAccCheck()
Gets the access control flag.
Specified by:
getAccCheck in interface ECCommand
Returns:
boolean - true if access control check is required for this command - 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.

Specified by:
getCommandContext in interface ECCommand
Returns:
CommandContext - The command context object.

getCommandIfName

public final java.lang.String getCommandIfName()
Gets the command interface name.
Specified by:
getCommandIfName in interface ECCommand
Parameters:
String - - 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.
Specified by:
getCommandName in interface ECCommand
Parameters:
String - - comamnd name

getDefaultProperties

public final TypedProperty getDefaultProperties()
Returns the default properties associated with this command.
Specified by:
getDefaultProperties in interface ECCommand
Returns:
TypedProperty - 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.

Specified by:
getResources in interface ECCommand
Returns:
AccessVector - a vector of resource action pairs

getStoreId

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

Specified by:
getStoreId in interface ECCommand
Returns:
Integer - The store Id.

getUser

public final UserAccessBean getUser()
                             throws ECSystemException
Gets the userAccessBean associated with the user.
Specified by:
getUser in interface ECCommand
Returns:
com.ibm.commerce.user.objects.UserAccessBean
Throws:
ECSystemException - The exception description.

getUserId

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

Specified by:
getUserId in interface ECCommand
Returns:
Long - the user Id.

isReadyToCallExecute

public boolean isReadyToCallExecute()
isReadyToCallExecute 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.

Specified by:
performExecute in interface ECCommand
Throws:
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.
Specified by:
setAccCheck in interface ECCommand
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

Specified by:
setCommandContext in interface ECCommand
Parameters:
commandContext - CommandContext - the command context object.

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.
Specified by:
setCommandIfName in interface ECCommand
Parameters:
name - String - the command interface name.

setDefaultProperties

public final void setDefaultProperties(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.
Specified by:
setDefaultProperties in interface ECCommand
Parameters:
value - TypedProperties

validateParameters

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

Specified by:
validateParameters in interface ECCommand
Throws:
ECException. -