atg.commerce.order.processor
Class BillingAddrValidatorImpl

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.order.processor.BillingAddrValidatorImpl
All Implemented Interfaces:
BillingAddrValidator, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class BillingAddrValidatorImpl
extends GenericService
implements BillingAddrValidator

This class provides a default implementation of BillingAddrValidator. By default the following address properties are checked :

If the address is an instance of atg.core.util.ContactInfo, the following properties may also be checked:


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
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
BillingAddrValidatorImpl()
           
 
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.
 boolean countryNeedsState(java.lang.String pCountry)
          Determine whether a state is required based on the country by consulting the property countriesWithStates.
 java.lang.String[] getCountriesWithStates()
          Return the list of countries for which a state or province is required to have a valid shipping address.
 boolean getValidateAddress1()
          Returns property validateAddress1
 boolean getValidateCity()
          Returns property validateCity
 boolean getValidateCountry()
          Returns the validateCountry flag
 boolean getValidateCounty()
          Returns property validateCounty
 boolean getValidateEmail()
          Returns the validateEmail flag
 boolean getValidateFaxNumber()
          Returns the validateFaxNumber flag
 boolean getValidateFirstName()
          Returns property validateFirstName
 boolean getValidateLastName()
          Returns property validateLastName
 boolean getValidatePhoneNumber()
          Returns the validatePhoneNumber flag
 boolean getValidatePostalCode()
          Returns property validatePostalCode
 boolean getValidateState()
          Returns property validateState
 boolean isEmpty(java.lang.String pStr)
          Return true if pStr is null or consists entirely of whitespace.
 void setCountriesWithStates(java.lang.String[] pCountriesWithStates)
          Specify the set of countries for which a state or province name is required in order to have a valid shipping address.
 void setValidateAddress1(boolean pValidateAddress1)
          Sets property validateAddress1
 void setValidateCity(boolean pValidateCity)
          Sets property validateCity
 void setValidateCountry(boolean pValidateCountry)
          Sets the validateCountry flag.
 void setValidateCounty(boolean pValidateCounty)
          Sets property validateCounty
 void setValidateEmail(boolean pValidateEmail)
          Sets the validateEmail flag.
 void setValidateFaxNumber(boolean pValidateFaxNumber)
          Sets the validateFaxNumber flag.
 void setValidateFirstName(boolean pValidateFirstName)
          Sets property validateFirstName
 void setValidateLastName(boolean pValidateLastName)
          Sets property validateLastName
 void setValidatePhoneNumber(boolean pValidatePhoneNumber)
          Sets the validatePhoneNumber flag.
 void setValidatePostalCode(boolean pValidatePostalCode)
          Sets property validatePostalCode
 void setValidateState(boolean pValidateState)
          Sets property validateState
 void validateBillingAddress(Address pAddr, java.lang.String pId, PipelineResult pResult, java.util.Locale pLocale)
          Verify that all required properties are present in a billing address.
 void validateBillingAddress(Address pAddr, java.lang.String pId, PipelineResult pResult, java.util.ResourceBundle pResources)
          This method validates the CreditCard properties.
protected  boolean validateEmailAddress(java.lang.String pEmail)
          Validates an email address for correctness.
protected  boolean validatePhoneNumber(java.lang.String pPhoneNumber)
          Validates a phone number for correctness.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, 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

BillingAddrValidatorImpl

public BillingAddrValidatorImpl()
Method Detail

validateBillingAddress

public void validateBillingAddress(Address pAddr,
                                   java.lang.String pId,
                                   PipelineResult pResult,
                                   java.util.Locale pLocale)
Verify that all required properties are present in a billing address.

Specified by:
validateBillingAddress in interface BillingAddrValidator
Parameters:
pAddr - The shipping address being examined.
pId - The id of the object that owns the shipping address, used in constructing error messages. For example, when validating the address in a shipping group, the caller might provide the shipping group id here.
pResult - A PipelineResult object in which to store error messages if any required values are missing from the address.
pLocale - The optional locale to use when looking up the resource bundle that contains error messages. If null, the default server locale will be used.

validateBillingAddress

public void validateBillingAddress(Address pAddr,
                                   java.lang.String pId,
                                   PipelineResult pResult,
                                   java.util.ResourceBundle pResources)
This method validates the CreditCard properties.

Specified by:
validateBillingAddress in interface BillingAddrValidator
Parameters:
cc - a CreditCard object to validate

setCountriesWithStates

public void setCountriesWithStates(java.lang.String[] pCountriesWithStates)
Specify the set of countries for which a state or province name is required in order to have a valid shipping address.

This property is a list of countries that the site can ship to for which a state (province) field is required in order to have a valid shipping address. For example, "usa" and "canada" might go on this list, but "germany" would not.

The country names in this list should be lower case and must be spelled as they would be spelled when the user enters or selects them. If the user chooses a country from a menu it is easy to make this list consistent with user input. If the user provides the name through a text input field, this list should contain common variations and misspellings, since the value in the list must match the user's input exactly except. Comparisons are case-insensitive, so it is not necessary to include all possible combinations of capitalization in this list.


getCountriesWithStates

public java.lang.String[] getCountriesWithStates()
Return the list of countries for which a state or province is required to have a valid shipping address.


countryNeedsState

public boolean countryNeedsState(java.lang.String pCountry)
Determine whether a state is required based on the country by consulting the property countriesWithStates.

Parameters:
pCountry - The country name being queried. If null, assume the country does require a state or province designation as part of the shipping address.
Returns:
true if the country is unspecified or the country is specified and appears in the list countriesWithStates, otherwise false.

validatePhoneNumber

protected boolean validatePhoneNumber(java.lang.String pPhoneNumber)
Validates a phone number for correctness. By default this method does nothing and returns true. This method can be overridden to do more sophisticated validation.


validateEmailAddress

protected boolean validateEmailAddress(java.lang.String pEmail)
Validates an email address for correctness. By default this method checks to see that there is one and only one @ character. This method can be overridden to do more sophisticated validation.


isEmpty

public boolean isEmpty(java.lang.String pStr)
Return true if pStr is null or consists entirely of whitespace.


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)

getValidateFirstName

public boolean getValidateFirstName()
Returns property validateFirstName

Returns:
returns property validateFirstName

setValidateFirstName

public void setValidateFirstName(boolean pValidateFirstName)
Sets property validateFirstName

Parameters:
pValidateFirstName - the value to set for property validateFirstName

getValidateLastName

public boolean getValidateLastName()
Returns property validateLastName

Returns:
returns property validateLastName

setValidateLastName

public void setValidateLastName(boolean pValidateLastName)
Sets property validateLastName

Parameters:
pValidateLastName - the value to set for property validateLastName

getValidateAddress1

public boolean getValidateAddress1()
Returns property validateAddress1

Returns:
returns property validateAddress1

setValidateAddress1

public void setValidateAddress1(boolean pValidateAddress1)
Sets property validateAddress1

Parameters:
pValidateAddress1 - the value to set for property validateAddress1

getValidateCity

public boolean getValidateCity()
Returns property validateCity

Returns:
returns property validateCity

setValidateCity

public void setValidateCity(boolean pValidateCity)
Sets property validateCity

Parameters:
pValidateCity - the value to set for property validateCity

getValidateCounty

public boolean getValidateCounty()
Returns property validateCounty

Returns:
returns property validateCounty

setValidateCounty

public void setValidateCounty(boolean pValidateCounty)
Sets property validateCounty

Parameters:
pValidateCounty - the value to set for property validateCounty

getValidateState

public boolean getValidateState()
Returns property validateState

Returns:
returns property validateState

setValidateState

public void setValidateState(boolean pValidateState)
Sets property validateState

Parameters:
pValidateState - the value to set for property validateState

getValidatePostalCode

public boolean getValidatePostalCode()
Returns property validatePostalCode

Returns:
returns property validatePostalCode

setValidatePostalCode

public void setValidatePostalCode(boolean pValidatePostalCode)
Sets property validatePostalCode

Parameters:
pValidatePostalCode - the value to set for property validatePostalCode

getValidateCountry

public boolean getValidateCountry()
Returns the validateCountry flag


setValidateCountry

public void setValidateCountry(boolean pValidateCountry)
Sets the validateCountry flag. If true, then the country property in the Address object will be validated.


getValidateEmail

public boolean getValidateEmail()
Returns the validateEmail flag


setValidateEmail

public void setValidateEmail(boolean pValidateEmail)
Sets the validateEmail flag. If true, then the email property in the ContactInfo object will be validated.


getValidatePhoneNumber

public boolean getValidatePhoneNumber()
Returns the validatePhoneNumber flag


setValidatePhoneNumber

public void setValidatePhoneNumber(boolean pValidatePhoneNumber)
Sets the validatePhoneNumber flag. If true, then the phoneNumber property in the ContactInfo object will be validated.


getValidateFaxNumber

public boolean getValidateFaxNumber()
Returns the validateFaxNumber flag


setValidateFaxNumber

public void setValidateFaxNumber(boolean pValidateFaxNumber)
Sets the validateFaxNumber flag. If true, then the faxNumber property in the ContactInfo object will be validated.