atg.commerce.order.processor
Class ProcVerifyOrderAddresses

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.logging.ApplicationLoggingImpl
          extended by atg.commerce.order.processor.ProcVerifyOrderAddresses
All Implemented Interfaces:
ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, PipelineProcessor

public class ProcVerifyOrderAddresses
extends ApplicationLoggingImpl
implements PipelineProcessor

This class verifies addresses for ShippingGroups and PaymentGroups. Specifically HardgoodShippingGroup and CreditCard. For each HardgoodShippingGroup and CreditCard class the address is verified against the configured address verification processor. Note that the AddressVerificationProcessor in no way is related to the PipelineProcessor interface which this class implements. The AddressVerificationProcessor is a class which implements the atg.payment.avs.AddressVerificationProcessor interface. By default the configured AddressVerificationProcessor is atg.commerce.payment.DummyAddressVerificationProcessor whose implementation is a noop. To extend this class to verify addresses in other class types, override the runProcess() method to call verifyAddress() for each address object in the desired classes then call this class' runProcess() method to verify the addresses in the HardgoodShippingGroup and CreditCard classes. To change the way addresses are verified override the verifyAddress() method. By default, verifyAddress() method calls verifyAddress() in the addressVerificationProcessor passing it a GenericAddressVerificationInfo object which it constructs using the parameter data passed into the method.

See Also:
AddressVerificationProcessor, DummyAddressVerificationProcessor, HardgoodShippingGroup, CreditCard, PipelineProcessor

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from interface atg.service.pipeline.PipelineProcessor
STOP_CHAIN_EXECUTION, STOP_CHAIN_EXECUTION_AND_COMMIT, STOP_CHAIN_EXECUTION_AND_ROLLBACK
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
ProcVerifyOrderAddresses()
           
 
Method Summary
protected  void addHashedError(PipelineResult pResult, java.lang.String pKey, java.lang.String pId, java.lang.Object pError)
          This method adds an error to the PipelineResult object.
protected  void cacheAddress(Address pAddress, AddressVerificationStatus pVerificationStatus)
          Cache the given address' verification status
 Cache getAddressVerificationCache()
          Returns the addressVerificationCache
 AddressVerificationProcessor getAddressVerificationProcessor()
          Returns the addressVerificationProcessor
protected  AddressVerificationStatus getCachedAddress(Address pAddress)
          Attempts to get the verification status of an address from the cache
 java.lang.String getLoggingIdentifier()
          Returns property LoggingIdentifier
 int[] getRetCodes()
          Returns the valid return codes 1 - The processor completed
protected  boolean hasBeenVerified(Address pAddress, java.lang.String pAddrId, PipelineResult pResult)
          Determines whether or not an address has already been verified.
 boolean isUseCache()
          Returns whether or not address verification results are being cached
 int runProcess(java.lang.Object pParam, PipelineResult pResult)
          This method executes the address verification.
 void setAddressVerificationCache(Cache pAddressVerificationCache)
          Sets the addressVerificationCache to be used to cache the results of verifying an address
 void setAddressVerificationProcessor(AddressVerificationProcessor pAddressVerificationProcessor)
          Sets the addressVerificationProcessor
 void setLoggingIdentifier(java.lang.String pLoggingIdentifier)
          Sets property LoggingIdentifier
 void setUseCache(boolean pUseCache)
          Sets whether or not the results from verifying an address should be cached
protected  boolean verifyAddress(java.lang.String pAddressId, Address pAddress1, Address pAddress2, PipelineResult pResult, OrderManager orderManager)
          This method verifies the addresses by going against the address verification system.
 
Methods inherited from class atg.nucleus.logging.ApplicationLoggingImpl
addGlobalLogListeners, addLogListener, getLoggingForVlogging, getLoggingIdentifer, getLogListenerCount, getLogListeners, initializeFromServiceEvent, isAutoInitListeners, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, removeLogListener, sendLogEvent, setAutoInitListeners, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

ProcVerifyOrderAddresses

public ProcVerifyOrderAddresses()
Method Detail

getRetCodes

public int[] getRetCodes()
Returns the valid return codes 1 - The processor completed

Specified by:
getRetCodes in interface PipelineProcessor
Returns:
an integer array of the valid return codes.

getAddressVerificationProcessor

public AddressVerificationProcessor getAddressVerificationProcessor()
Returns the addressVerificationProcessor


setAddressVerificationProcessor

public void setAddressVerificationProcessor(AddressVerificationProcessor pAddressVerificationProcessor)
Sets the addressVerificationProcessor


setUseCache

public void setUseCache(boolean pUseCache)
Sets whether or not the results from verifying an address should be cached

Parameters:
pUseCache - true if results should be cached

isUseCache

public boolean isUseCache()
Returns whether or not address verification results are being cached

Returns:
true if the results are being cached

setAddressVerificationCache

public void setAddressVerificationCache(Cache pAddressVerificationCache)
Sets the addressVerificationCache to be used to cache the results of verifying an address

Parameters:
pAddressVerificationCache - cache to use

getAddressVerificationCache

public Cache getAddressVerificationCache()
Returns the addressVerificationCache

Returns:
the addressVerificationCache

setLoggingIdentifier

public void setLoggingIdentifier(java.lang.String pLoggingIdentifier)
Sets property LoggingIdentifier

Overrides:
setLoggingIdentifier in class ApplicationLoggingImpl

getLoggingIdentifier

public java.lang.String getLoggingIdentifier()
Returns property LoggingIdentifier

Overrides:
getLoggingIdentifier in class ApplicationLoggingImpl

runProcess

public int runProcess(java.lang.Object pParam,
                      PipelineResult pResult)
               throws java.lang.Exception
This method executes the address verification. It searches through the ShippingGroup and PaymentGroup lists in the Order for HardgoodShippingGroup and CreditCard objects. It then gets the address from them and calls verifyAddress(). This method requires that an Order and an OrderManager object be supplied in pParam in a HashMap. Use the PipelineConstants class' static members to key the objects in the HashMap.

Specified by:
runProcess in interface PipelineProcessor
Parameters:
pParam - a HashMap which must contain an Order and OrderManager object
pResult - a PipelineResult object which stores any information which must be returned from this method invokation
Returns:
an integer specifying the processor's return code
Throws:
java.lang.Exception - throws any exception back to the caller
See Also:
PipelineProcessor.runProcess(Object, PipelineResult)

verifyAddress

protected boolean verifyAddress(java.lang.String pAddressId,
                                Address pAddress1,
                                Address pAddress2,
                                PipelineResult pResult,
                                OrderManager orderManager)
                         throws CommerceException
This method verifies the addresses by going against the address verification system. It creates and instance of AddressVerificationInfo and sets the data supplied in the method parameters into that object. Then using that object calls verifyAddress() on the addressVerificationProcessor. If an address is invalid the error is added to the PipelineResult object. Override this method to change the way address verification is done.

Parameters:
pAddressId - the id to reference this address verification with
pAddress1 - the first address to verify. Cannot be null.
pAddress2 - the second address to verify. Can be null.
pResult - a PipelineResult object which stores any information which must be returned from this method invokation
orderManager - an instance of the OrderManager
Returns:
true if the addresses were correct, false otherwise
Throws:
InvalidParameterException - if pAddressId or pBillingAddress is null
CommerceException
See Also:
AddressVerificationProcessor.verifyAddress(AddressVerificationInfo)

addHashedError

protected void addHashedError(PipelineResult pResult,
                              java.lang.String pKey,
                              java.lang.String pId,
                              java.lang.Object pError)
This method adds an error to the PipelineResult object. This method, rather than just storing a single error object in pResult, stores a Map of errors. This allows more than one error to be stored using the same key in the pResult object. pKey is used to reference a HashMap of errors in pResult. So, calling pResult.getError(pKey) will return an object which should be cast to a Map. Each entry within the map is keyed by pId and its value is pError.

Parameters:
pResult - the PipelineResult object supplied in runProcess()
pKey - the key to use to store the HashMap in the PipelineResult object
pId - the key to use to store the error message within the HashMap in the PipelineResult object
pError - the error object to store in the HashMap
See Also:
PipelineResult, runProcess(Object, PipelineResult)

cacheAddress

protected void cacheAddress(Address pAddress,
                            AddressVerificationStatus pVerificationStatus)
Cache the given address' verification status

Parameters:
pAddress - address whose verification status is being cached
pVerificationStatus - verification status to cache

getCachedAddress

protected AddressVerificationStatus getCachedAddress(Address pAddress)
                                              throws java.lang.Exception
Attempts to get the verification status of an address from the cache

Parameters:
pAddress - Address to retrieve
Returns:
the verification status if it was cached, otherwise null.
Throws:
java.lang.Exception

hasBeenVerified

protected boolean hasBeenVerified(Address pAddress,
                                  java.lang.String pAddrId,
                                  PipelineResult pResult)
Determines whether or not an address has already been verified. If it has been verified, but that verification was false then an error is added to the Pipeline Result

Parameters:
pAddress - Address to verify
pAddrId - Id of the address to verify
pResult - pipeline result
Returns:
true if the address has already been verified (regardless of the verification result), false otherwise.