Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleMYCOMPANYTucanoParametersPayeezyParameter.java
linenumberstrue
collapsetrue
package payeezy.dataobject.paymentgateway.payeezy;
import com.crm.dataobject.ICRMLookupEnum;

public enum PayeezyParameter implements ICRMLookupEnum{
	
	MODE("key_mode", "String",1),
	TEST_URL("key_url", "String",2),
	TEST_MERCHANT_TOKEN("key_merchant_token", "String",3),
	TEST_TA_TOKEN("key_transarmor_token", "String",4),
	TEST_API_KEY("key_api_key", "String",5),
	TEST_API_SECRET("key_api_secret", "String",6),
	TEST_JS_SECURITY_KEY("key_js_security_key", "String",7),
	LIVE_URL("key_url", "String",2),
	LIVE_MERCHANT_TOKEN("key_merchant_token", "String",3),
	LIVE_TA_TOKEN("key_transarmor_token", "String",4),
	LIVE_API_KEY("key_api_key", "String",5),
	LIVE_API_SECRET("key_api_secret", "String",6),
	LIVE_JS_SECURITY_KEY("key_js_security_key", "String",7);

	private String label;
	private String type;
	private Integer order;
	 
	private PayeezyParameter(String label, String type, Integer order) {
		this.label = label;
		this.type = type;
		this.order = order;
	}
	@Override
	public String getLabel() {
		return label;
	}
	public String getType() {
		return type;
	}
	public Integer getOrder() {
		return order;
	}
}

...

More details on creating a provisioning provider business object class can be found in the next section.

3.

...

Payment Gateway Business Object Class

The new custom business object class must extend extend com.crm.businessobject.provisioningpaymentgateway.CRMBOProvProviderBeanCRMBOPaymentGatewaySettingBean

 and implement com.crm.businessobject.ICRMBOProvisioningProvider interface and its five methods:

...

Code Block
languagejava
titleMYCOMPANYCRMBOTucanoProviderBean.java
linenumberstrue
collapsetrue
public class MYCOMPANYCRMBOTucanoProviderBean extends CRMBOProvProviderBean implements ICRMBOProvisioningProvider  {

	@EJB private MYCOMPANYTucanoProviderXMLUtilBean tucanoProviderXMLUtilBean;
	@EJB private CRMBOProvProviderServiceBean provProviderServiceBean;
	@EJB private CRMValidatorBean validatorBean;
	@EJB private CRMBOProvisioningDistributorBean provisioningDistributorBean;
    /**
     * Default constructor. 
     */
    public MYCOMPANYCRMBOTucanoProviderBean() {
    	// do nothing
    }
    /**
     * Loads the effective TUCANO provisioning provider
     * @return the effective TUCANO provisioning provider
     * @throws Exception
     */
	public CRMDOProvProvider loadEffective() throws Exception {
		return loadEffective(MYCOMPANYCRMProcessTucanoProviderBean.PROVIDER_PROTOCOL);
	}
	
	/**
	 * Loads the effective TUCANO provisioning provider
	 * @param applicationServerFiltering - if set to true filters out the results based on the provisioning provider's allowed application servers
	 * @return the effective TUCANO provisioning provider
	 * @throws Exception
	 */
	public CRMDOProvProvider loadEffective(Boolean applicationServerFiltering) throws Exception {
		return loadEffective(MYCOMPANYCRMProcessTucanoProviderBean.PROVIDER_PROTOCOL, applicationServerFiltering);
	}
	/**
	 * Loads the TUCANO provisioning provider
	 * @return the TUCANO provisioning provider
	 * @throws Exception
	 */
	public CRMDOProvProvider load() throws Exception {
		return loadByProtocol(MYCOMPANYCRMProcessTucanoProviderBean.PROVIDER_PROTOCOL);
	}
	
	/**
     * Constructs a TUCANO provisioning providerpackage payeezy.businessobject.paymentgateway.payeezy;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Set;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import com.crm.businessobject.CRMValidatorBean;
import com.crm.businessobject.paymentgateway.CRMBOPaymentGatewayParameterBean;
import com.crm.businessobject.paymentgateway.CRMBOPaymentGatewayParameterValueBean;
import com.crm.businessobject.paymentgateway.CRMBOPaymentGatewaySettingBean;
import com.crm.businessobject.platform.CRMBOCurrencyBean;
import com.crm.dataobject.CRMDO;
import com.crm.dataobject.paymentgateway.CRMDOPaymentGatewayParameter;
import com.crm.dataobject.paymentgateway.CRMDOPaymentGatewayParameterValue;
import com.crm.dataobject.paymentgateway.CRMDOPaymentGatewaySetting;
import com.crm.dataobject.paymentgateway.PaymentGatewayCardBrand;
import com.crm.dataobject.paymentgateway.PaymentGatewayLifeCycleState;
import com.crm.dataobject.platform.CRMDOCurrency;
import com.crm.exception.DAOException;
import com.crm.exception.MandatoryFieldException;
import com.crm.framework.service.ServiceUtil;
import payeezy.dataobject.paymentgateway.payeezy.PayeezyParameter;
import payeezy.dataobject.paymentgateway.payeezy.PayeezyMode;
/**
 * Session Bean implementation class PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean
 */
@Stateless
@LocalBean
public class PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean extends CRMBOPaymentGatewaySettingBean {
       
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@EJB private CRMValidatorBean validatorBean;
	@EJB private CRMBOCurrencyBean currencyBean;
	@EJB private CRMBOPaymentGatewayParameterBean paymentGatewayParameterBean;
	@EJB private CRMBOPaymentGatewayParameterValueBean paymentGatewayParameterValueBean;
	
	public final static String GENERAL_PARAMETERS = "GENERAL_PARAMETERS";
	public final static String PROTOCOL = "PAYEEZY";
	/**
     * @see CRMBOPaymentGatewaySettingBean#CRMBOPaymentGatewaySettingBean()
     */
    public PAYEEZYCRMBOPayeezyPaymentGatewaySettingBean() {
        super();
    }
    /**
     * Constructs a payment gateway setting.
     * 
     * @param mainDTO - the main data object
     * @return a TUCANOpayment provisioninggateway providersetting
     * @throws Exception
     */
	@Override
	protected CRMDO constructDO(CRMDO mainDTO) throws Exception {
		
		CRMDOProvProviderCRMDOPaymentGatewaySetting provProviderpaymentGatewaySetting = (CRMDOProvProviderCRMDOPaymentGatewaySetting)super.constructDO(mainDTO);
		
		MYCOMPANYTucanoParameters tucanoParameters = new MYCOMPANYTucanoParameters(paymentGatewaySetting.setPaymentGatewayProtocol(PROTOCOL);	
		provProvider.setProvisioningParameters(tucanoParameters);
		
		provProvider.setProtocol(MYCOMPANYCRMProcessTucanoProviderBean.PROVIDER_PROTOCOL);
		provProvider.setLifeCycleState(ProvProviderLifeCycleStatepaymentGatewaySetting.setLifeCycleState(PaymentGatewayLifeCycleState.NOT_EFFECTIVE);
		provProvider = setDefaultSettings(provProvider);
return paymentGatewaySetting;		
		return}
provProvider;		
	}
    
	/**
	     * ReturnsValidates thea mandatorypayeezy fieldspayment ofgateway thesetting givenon provisioning providersave.
    	 * 
    	 * @param dto - the payment provisioninggateway providersetting to return the mandatory fields for
     * @return the mandatory fields of the provisioning provider
     * validate
	 * @throws Exception
	     */
	@Override
	protected LinkedHashMap<String, String> getMandatoryFieldsvoid validateDOonSave(CRMDO dto) throws Exception {
		super.validateDOonSave(dto);
		LinkedHashMap<String,CRMDOPaymentGatewaySetting String>paymentGatewaySetting mandatoryFields = super.getMandatoryFields(CRMDOPaymentGatewaySetting)dto);
			
		mandatoryFields.put("key_url", "provisioningParameters/url"validateAuthenticationSettings(paymentGatewaySetting);
		mandatoryFields.put("key_identity_key", "provisioningParameters/identityKey");
		mandatoryFields.put("key_username", "provisioningParameters/username");
		mandatoryFields.put("key_password", "provisioningParameters/password");
		mandatoryFields.put("key_language_id", "provisioningParameters/languageID");
		mandatoryFields.put("key_default_product_id", "provisioningParameters/defaultProductID");
		mandatoryFields.put("key_stb_material_id", "provisioningParameters/stbMaterialID");
		mandatoryFields.put("key_provider_id", "provisioningParameters/providerID");
		mandatoryFields.put("key_tve_adapter", "provisioningParameters/tveAdapter");
		mandatoryFields.put("key_jwt_key", "provisioningParameters/jwtKey");
		mandatoryFields.put("key_jwt_expiration_time_in_seconds", "provisioningParameters/jwtExpirationTimeInSeconds");
		mandatoryFields.put("key_address_country", "provisioningParameters/addressCountry");
		
		return mandatoryFields;
	}
	
	/**
	 * Sets provisioning provider's connection parameter values using its 'parameters' String property value
	 * @param provProvider - the provisioning provider to set the objects to
	 * @return the updated provisioning provider
	 */
	public CRMDOProvProvider setObjectsFromXML(CRMDOProvProvider provProvider) throws Exception {
		if (provProvider.getParameters()!=null)
		{	
			provProvider = tucanoProviderXMLUtilBean.loadConnectionParametersFromXml(provProvider);
		}
		
		return provProvider;
	}
	/**
	 * Constructs a String XML that will keep all information about the provider's connection parameters and set it to CRMDOProvProvider object's 'parameters' String property
	 * @param provProvider - the provisioning provider to construct the XML}
    
	
	/**
	 * Validates the authentication settings of the payment gateway setting
     * 
     * @param paymentGatewaySetting - the payment gateway setting to validate
     * @throws Exception
     */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	private void validateAuthenticationSettings(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
		if(paymentGatewaySetting.getPaymentGatewayParameters()==null || !ServiceUtil.isInitialized(paymentGatewaySetting.getPaymentGatewayParameters()))
		{
			paymentGatewaySetting.setPaymentGatewayParameters(new HashSet(paymentGatewayParameterBean.load(paymentGatewaySetting)));
		}
		PayeezyMode mode = getMode(paymentGatewaySetting.getPaymentGatewayParameters());
		if(mode==null)
		{
			throw new MandatoryFieldException(getCRMSession(), PayeezyParameter.MODE.getLabel());
		}
		
		if(mode.equals(PayeezyMode.TEST))
		{
			if(!exists(PayeezyParameter.TEST_MERCHANT_TOKEN, paymentGatewaySetting.getPaymentGatewayParameters()))
			{
				throw new MandatoryFieldException(getCRMSession(), PayeezyParameter.TEST_MERCHANT_TOKEN.getLabel());
			}
			if(!exists(PayeezyParameter.TEST_API_KEY, paymentGatewaySetting.getPaymentGatewayParameters()))
			{
				throw new MandatoryFieldException(getCRMSession(), PayeezyParameter.TEST_API_KEY.getLabel());
			}
			if(!exists(PayeezyParameter.TEST_API_SECRET, paymentGatewaySetting.getPaymentGatewayParameters()))
			{
				throw new MandatoryFieldException(getCRMSession(), PayeezyParameter.TEST_API_SECRET.getLabel());
			}
			if(!exists(PayeezyParameter.TEST_URL, paymentGatewaySetting.getPaymentGatewayParameters()))
			{
				throw new MandatoryFieldException(getCRMSession(), PayeezyParameter.TEST_URL.getLabel());
			}
		}
		else if(mode.equals(PayeezyMode.LIVE))
		{
			if(!exists(PayeezyParameter.LIVE_MERCHANT_TOKEN, paymentGatewaySetting.getPaymentGatewayParameters()))
			{
				throw new MandatoryFieldException(getCRMSession(), PayeezyParameter.LIVE_MERCHANT_TOKEN.getLabel());
			}
			if(!exists(PayeezyParameter.LIVE_API_KEY, paymentGatewaySetting.getPaymentGatewayParameters()))
			{
				throw new MandatoryFieldException(getCRMSession(), PayeezyParameter.LIVE_API_KEY.getLabel());
			}
			if(!exists(PayeezyParameter.LIVE_API_SECRET, paymentGatewaySetting.getPaymentGatewayParameters()))
			{
				throw new MandatoryFieldException(getCRMSession(), PayeezyParameter.LIVE_API_SECRET.getLabel());
			}
			if(!exists(PayeezyParameter.LIVE_URL, paymentGatewaySetting.getPaymentGatewayParameters()))
			{
				throw new MandatoryFieldException(getCRMSession(), PayeezyParameter.LIVE_URL.getLabel());
			}
		}
	}
	
	@SuppressWarnings({ "unchecked", "rawtypes" })
	private PayeezyMode getMode(Set<CRMDOPaymentGatewayParameter> parameters) throws DAOException, Exception{
		PayeezyMode mode = null;
		if(parameters!=null)
		{
			Iterator<CRMDOPaymentGatewayParameter> iter = parameters.iterator();
			while(iter.hasNext())
			{
				CRMDOPaymentGatewayParameter parameter = iter.next();
				if(parameter!=null &&
					
						parameter.getName()!=null &&
						parameter.getName().equals(PayeezyParameter.MODE.toString()))
				{
					Set<CRMDOPaymentGatewayParameterValue> values = parameter.getParameterValues();
					
					if(values==null || !ServiceUtil.isInitialized(values))
					{
						values = new HashSet(paymentGatewayParameterValueBean.load(parameter));
					}
					
					if(values!=null)
					{
						Iterator<CRMDOPaymentGatewayParameterValue> valueIter = values.iterator();
						while(valueIter.hasNext())
						{
							CRMDOPaymentGatewayParameterValue value = valueIter.next();
							if(value!=null)
							{
								mode = PayeezyMode.valueOf(PayeezyMode.class,value.getStringValue());
								break;
							}
						}
					}
				}
				
				if(mode!=null)
				{
					break;
				}
			}
		}
		
		
		return mode;
	}
	
	private boolean exists(PayeezyParameter PayeezyParameter, Set<CRMDOPaymentGatewayParameter> parameters){
		boolean exists = false;
		
		if(parameters!=null)
		{
			for(CRMDOPaymentGatewayParameter parameter:parameters)
			{
				if(parameter!=null &&
						parameter.getName()!=null &&
						parameter.getName().equals(PayeezyParameter.toString()) &&
						parameter.getParameterValues()!=null &&
						parameter.getParameterValues().size()>0)
				{
					
					Iterator<CRMDOPaymentGatewayParameterValue> iter = parameter.getParameterValues().iterator();
					while(iter.hasNext())
					{
						CRMDOPaymentGatewayParameterValue value = iter.next();
						if(value.getStringValue()!=null)
						{
							exists  = true;
							break;
						}
					}
					
					if(exists)
					{
						break;
					}
				}
			}
		}
		
		return exists;
	}
	
	
	/**
	 * Constructs an XML file from a payment gateway setting.
	 * 
	 * @param paymentGatewaySetting - the payment gateway setting to get the values from
	 * @return the payment gateway setting
	 * @throws Exception
	 */
	@Override
	public CRMDOPaymentGatewaySetting setXMLFromObjects(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
			
		return paymentGatewaySetting;
	}
	
	/**
	 * Sets the values of a payment gateway setting from an XML file.
	 * 
	 * @param paymentGatewaySetting - the payment gateway setting to set the values for
	 * @return the updated provisioning provider payment gateway setting
	 * @throws Exception
	 */
	@Override
	public CRMDOProvProviderCRMDOPaymentGatewaySetting setXMLFromObjectssetObjectsFromXML(CRMDOProvProviderCRMDOPaymentGatewaySetting provProviderpaymentGatewaySetting) throws Exception {
		if
(provProvider!=null)
		{
			provProvider = tucanoProviderXMLUtilBean.convertConnectionParametersToXML(provProvider)return paymentGatewaySetting;
		}
		
		return provProvider;
	}
	/**
	 * Returns a unique identification string (conditional access id) used by the provisioning
provider to identify the given service
	 * @param provProvider -Loads the provisioningpayeezy providerpayment togateway getsetting.
the service ca id for 	 * @param product -
the product to get its service ca id
	 * @return thea product's service ca id
	 */
	public String getServiceCAID(CRMDOProvProvider provProvider, CRMDOProduct product) throws Exception {
		String serviceCAID = null;
		
		CRMDOProvProviderService provProviderService = provProviderServiceBean.load(provProvider, product); 
		
		if (provProviderService!=null)
		{
			serviceCAID = provProviderService.getValue();
		}
		
		return serviceCAID;
	}payeezy payment gateway setting
     * @throws Exception
     */
	public CRMDOPaymentGatewaySetting load() throws Exception {
		return loadByProtocol(PROTOCOL);
	}
	
	/**
	 * Returns a unique identification* stringLoads (conditionalthe accesseffective id)payeezy usedpayment bygateway thesetting.
provisioning provider to identify the given smartcard
	 * @param
provProvider - the provisioning provider to* get@return the smartcardeffective capayeezy idpayment forgateway 	setting
* @param installedItem - the smartcard* installed item to get its ca id
	 * @return the smartcard ca id
	@throws Exception
     */
	public StringCRMDOPaymentGatewaySetting getSmartcardCAID(CRMDOProvProvider provProvider, CRMDOInstalledItem installedItemloadEffective() throws Exception {
		return installedItem.getAltCodeloadEffective(PROTOCOL);
	}
	
	/**
	 * Returns a unique identification* stringLoads (conditionalthe accesseffective id)payeezy usedpayment bygateway thesetting.
provisioning provider to identify the given set-top* box
	 * @param provProviderapplicationServerFiltering - the provisioning provider to get the set-top box ca id for
	 * @param installedItem - the set-top box installed item to get its ca id
	 * @return the set-top box ca id
	if true, result will be filtered based on allowed application servers
     * @return the effective payeezy payment gateway setting
     * @throws Exception
     */
	public StringCRMDOPaymentGatewaySetting getSTBCAIDloadEffective(CRMDOProvProvider provProvider, CRMDOInstalledItem installedItemBoolean applicationServerFiltering) throws Exception {
		return installedItem.getAltCode();
	}
	
	/**
	 * Validates a provisioning provider service on save.
	 * 
	loadEffective(PROTOCOL, applicationServerFiltering);
	}
	
	/**
     * Returns the mandatory fields of a payeezy payment gateway setting.
     * 
     * @param provProviderdto - the payeezy payment provisioninggateway providersetting to validatereturn it'sthe provisioningmandatory providerfields servicefor
	 * @throws Exception 	 */ 	@Override
	@SuppressWarnings({ "unchecked", "rawtypes" })
	protected void validateOnSaveProvisioningProviderServices(CRMDOProvProvider provProvider) throws Exception, AtLeastOneRecordException, MandatoryFieldException, InvalidValueException {
		if(!ServiceUtil.isInitialized(provProvider.getServices())
			|| provProvider.getServices() == null
			|| provProvider.getServices().size() == 0)
		{
			provProvider.setServices(new HashSet(provProviderServiceBean.load(provProvider)));
		}
			
		if(provProvider.getServices() != null && provProvider.getServices().size() > 0)
		{
			Iterator<CRMDOProvProviderService> iterServices	= provProvider.getServices().iterator@return the mandatory fields of the payeezy payment gateway setting
     * @throws Exception
     */
	@Override
	protected LinkedHashMap<String, String> getMandatoryFields(CRMDO dto) throws Exception {
		LinkedHashMap<String, String> mandatoryFields = new LinkedHashMap<String,String>();
			
			while (iterServices.hasNext())
			{
				CRMDOProvProviderService service = (CRMDOProvProviderService) iterServices.next();
				
				CRMDOProduct product 				= service.getProduct();
				if (service.getIsDeleted()!=null && service.getIsDeleted().equals(new Integer(0)) && product.getType().getIsForProvision().equals(new Integer(1) ) )
				{
					if (service.getValue() == null)
					{
						throw new MandatoryFieldException(getCRMSession(), "key_provisioning_system_identifier");
					}
					
					if(!StringUtil.isNumeric(service.getValue()))
			    	{
						throw new InvalidValueException(null,"Provisioning System Identifier."+StringUtil.getNumericExceptionMessage(service.getValue()));
			    	}
				}
			}
			
			provProviderServiceBean.validateOnSave(new ArrayList<CRMDO>(provProvider.getServices()));
			
			validatorBean.validateUniqueRecord(
					"provisioning provider service", 
					new ArrayList<CRMDO>(provProvider.getServices()), 
					new String[]{"product.code"}, 
					new String[]{"service"});
			
		}
		else
		{
			throw new AtLeastOneRecordException(getCRMSession(), "key_service");
		}mandatoryFields.put("key_name", "name");
		mandatoryFields.put("key_alternative_code", "altCode");
		mandatoryFields.put("key_life_cycle_state", "lifeCycleState");
		mandatoryFields.put("key_payment_gateway", "paymentGatewayProtocol");
	
		return mandatoryFields;
	}
	
	
	/**
	 * Validates the uniqueness of a payment gateway setting.
	 * 
	 * @param paymentGatewaySetting - the payment gateway setting to validate
	 * @throws Exception
	 */
	@Override
	protected void validateUniqueness(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
				
		String[] fieldNames = new String[] {"name", "altCode", "paymentGatewayProtocol"};
		String[] msgKeys = new String[] {"Name", "Alternative Code", "Protocol"};
		
		validatorBean.validateUniqueRecordAgainstDb(
				paymentGatewaySetting, 
				fieldNames, 
				msgKeys, 
				"Payeezy Payment Gateway Setting", 
				true, 
				null);
	}
	@Override
	public CRMDOPaymentGatewaySetting initializeParameters(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception
	{
		return paymentGatewaySetting;
	}
	
	/**
	 * Get Validatesthe currencies awhich provisioningare distributorsupported onby save.payeezy
	 * 
	 * @param provProvider -@return a list of all the currencies provisioningwhich providerare tosupported validateby it'spayeezy provisioning distributor
	 * @throws Exception
	 */
	@Override
	@SuppressWarnings({ "unchecked", "rawtypes" })
	protected void validateOnSaveProvisioningDistributors(CRMDOProvProvider provProvider) throws Exception, AtLeastOneRecordException {
		if(!ServiceUtil.isInitialized(provProvider.getProvisioningDistributors())
			|| provProvider.getProvisioningDistributors() == null
			|| provProvider.getProvisioningDistributors().size() == 0)
public ArrayList<CRMDO> getSupportedCurrencies(CRMDOPaymentGatewaySetting paymentGatewaySetting) throws Exception {
		
		ArrayList<CRMDO> supportedCurrencies = currencyBean.loadAltenativeCurrencies();
		CRMDOCurrency defaultCurrency = getCRMSession().getGeneralSettings().getDefaultCurrency();
					
		if (supportedCurrencies!=null && supportedCurrencies.size()>0)
		{
			Boolean defaultFound=false;
			for (int i=0; i<supportedCurrencies.size(); i++)
			{
			provProvider.setProvisioningDistributors(new HashSet(provisioningDistributorBean.load(provProvider)));
		}
		
		if(provProvider.getProvisioningDistributors() != null && provProvider.getProvisioningDistributors().size() > 0)
	CRMDOCurrency currency = (CRMDOCurrency) supportedCurrencies.get(i);
				if(currency.equals(defaultCurrency))
				{
					defaultFound=true;
					break;
				}
			}
			
			if(!defaultFound)
			{
			Iterator<CRMDOProvisioningDistributor> iter = provProvider.getProvisioningDistributors().iterator();	supportedCurrencies.add(defaultCurrency);			
			Boolean}
nonDeletedExists = new Boolean(false)		}
				
		return supportedCurrencies;
	}
	
	/**
	 * Returns the card brand based on the payeezy card type
		while(iter.hasNext())
			 * @param cardType - the given payeezy card type
	 * @return the card brand
	 */
	public String getCardBrand(String cardType){
				CRMDOProvisioningDistributorString provisioningDistributorbrand = (CRMDOProvisioningDistributor)iter.next()null;
		if(cardType!=null)
		{
				if(!provisioningDistributor.isDeleted(cardType.equalsIgnoreCase("American Express"))
				{
					if(nonDeletedExists)brand = PaymentGatewayCardBrand.AMERICAN_EXPRESS.toString();
					{}
						throw new OnlyOneRecordException(getCRMSession(), "key_provisioning_distributor");else if(cardType.equalsIgnoreCase("Discover"))
					}	{
					
					nonDeletedExists = new Boolean(truebrand = PaymentGatewayCardBrand.DISCOVER.toString();
				}	
			}	else if(cardType.equalsIgnoreCase("MasterCard"))
			{
				if(provProvider.getLifeCycleState() != null && provProvider.getLifeCycleState().equals(ProvProviderLifeCycleState.EFFECTIVE) && !nonDeletedExists)
			{brand = PaymentGatewayCardBrand.MASTER_CARD.toString();
			}
				throw new AtLeastOneRecordException(getCRMSession(), "key_provisioning_distributors");else if(cardType.equalsIgnoreCase("Visa"))
			}{
	
			
			provisioningDistributorBean.validateOnSave(new ArrayList<CRMDO>(provProvider.getProvisioningDistributors())brand = PaymentGatewayCardBrand.VISA.toString();
			}
			else
			{
			if(provProvider.getLifeCycleState() != null && provProvider.getLifeCycleState().equals(ProvProviderLifeCycleState.EFFECTIVE))	brand = PaymentGatewayCardBrand.UNKNOWN.toString();
			{}
		}
		throw
new AtLeastOneRecordException(getCRMSession(), "key_provisioning_distributors");
			}	
		}		return brand;
	}
	
	/**
	 * ValidatesReturns athe provisioningcard providertype physical goodbased on save.the 	card *brand

	 * @param provProvidercardType - the provisioninggiven providercard tobrand
validate	 it's* physical@return goodthe 	card *brand
@throws Exception
	 */
	@Overridepublic 	protected void validateOnSaveProvisioningProviderPhysicalGood(CRMDOProvProvider provProvider) throws Exception, AtLeastOneRecordException String getCardType(String brand){
		String cardType = null;
		if(brand!=null)
		{
			if (isCollectionModified(provProvider.getPhysicalGoodsbrand.equals(PaymentGatewayCardBrand.AMERICAN_EXPRESS.toString()))
			{
			Set<CRMDOProvProviderPhysicalGood> physicalGoods = provProvider.getPhysicalGoods();
			Iterator<CRMDOProvProviderPhysicalGood> physicalGoodIter = physicalGoods.iterator()	cardType ="American Express";
			int physicalGoodCounter = 0;
}
			
			while (physicalGoodIter.hasNextelse if(brand.equals(PaymentGatewayCardBrand.DISCOVER.toString()))
			{
				CRMDOProvProviderPhysicalGoodcardType physicalGood	= physicalGoodIter.next()"Discover";
				}
				else if (physicalGoodbrand.getIsDeleted().equals(new Integer(0equals(PaymentGatewayCardBrand.MASTER_CARD.toString()))
				{
					physicalGoodCounter++;
				}cardType = "MasterCard";
			}
			else 			if (physicalGoodCounter == 0if(brand.equals(PaymentGatewayCardBrand.VISA.toString()))
			{
				throwcardType new AtLeastOneRecordException(getCRMSession(), "key_physical_good")= "Visa";
			}
		}
		
		super.validateOnSaveProvisioningProviderPhysicalGood(provProvider)return cardType;
	}
	}
	...
}

4. User Interface Classes

...