com.ibm.commerce.command
Class AbstractECTargetableCommand

com.ibm.commerce.command.AbstractECTargetableCommand
All Implemented Interfaces:
ECCommand, ECTargetableCommand
Direct Known Subclasses:
ControllerCommandImpl, DataBeanCommandImpl

public abstract class AbstractECTargetableCommand
implements ECTargetableCommand

This is the abstract base class for all commerce ECTargetableCommands


Field Summary
protected  CommandContext commandContext
           
 
Fields inherited from interface com.ibm.commerce.command.ECTargetableCommand
COPYRIGHT
 
Fields inherited from interface com.ibm.commerce.command.ECCommand
defaultCommandClassName
 
Constructor Summary
AbstractECTargetableCommand()
           
 
Method Summary
 boolean accessControlCheck()
          Performs command level access control check.
 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 for execution of a command.
 void finalize()
          Final clean up of resources.
 boolean getAccCheck()
          Check to see if access control check is required for this command.
 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 Targettable Command frame work before the execution of the command.
 void performExecute()
          The business logic for this command.
 void reset()
          This method should be called after a command has been executed to reset its states variables.
 void setAccCheck(boolean newValue)
          This method is set by the web controller to indicate whether access control check is required 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 val)
          Sets default properties associated with this ECCommand.
 void validateParameters()
          This is where parameter checking is done.
 

Field Detail

commandContext

protected CommandContext commandContext
Constructor Detail

AbstractECTargetableCommand

public AbstractECTargetableCommand()
Method Detail

accessControlCheck

public boolean accessControlCheck()
                           throws ECException
Performs command level access control check. The default implementation invokes the access control manager to perform the command level access control check on this command.
Returns:
boolean - true if user has authority to execute this command - false if user has no authority to execute this command
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 final void execute()
                   throws ECException
This method is part of the command framework for execution of a command. An ECException will be throw if there are any errors detected during the command execution.

Specified by:
execute in interface ECCommand
Throws:
ECException -  

finalize

public void finalize()
Final clean up of resources.

getAccCheck

public boolean getAccCheck()
Check to see if access control check is required for this command.
Specified by:
getAccCheck in interface ECCommand
Returns:
boolean - true if access check is required - false if access check is not required

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 on the resource.

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

getStoreId

public 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 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 Targettable Command frame work 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
The business logic for this command. This method should be overwritten by all command writers. Command writers should call super.performExecute() as the first line in their method.

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

reset

public void reset()
This method should be 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)
This method is set by the web controller to indicate whether access control check is required for this command. For example, no access control check is required when we display a jsp page associated with a command because access control has already been performed on the controller 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.
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
Specified by:
setCommandIfName in interface ECCommand
Parameters:
name - String - the command interface name.

setDefaultProperties

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

validateParameters

public void validateParameters()
                        throws ECException
This is where parameter checking is done. This method replaces checkParameters() in 5.1. The default implementation of validateParameters() is a no op. It is the responsibility of the command writers to implements this method if they want to perform server side parameter checking.

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