Create a custom sms provider
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
package com.crm.process.smsproviders;
import java.util.HashMap;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import com.crm.businessobject.smsproviders.CRMBOSMSProviderBean;
import com.crm.dataobject.smsproviders.CRMDOSMSProvider;
import com.crm.dataobject.smsproviders.SendSMSParameters;
import com.crm.framework.util.CallList;
import com.crm.framework.util.ExceptionUtil;
@Stateless(mappedName = "ejb/CUSTOMCRMProcessCustomSMSProvider")
@LocalBean
public class CUSTOMCRMProcessCustomSMSProviderBean extends CRMProcessSMSProvidersBean{
/**
*
*/
private static final long serialVersionUID = 1L;
@EJB private CRMBOSMSProviderBean smsProviderBean;
private final String ALIAS_PASSWORD = "password";
private final String ALIAS_USERNAME = "username";
private final String ALIAS_FROM = "commFrom";
public static String PROVIDER_PROTOCOL = "CUSTOM";
@Override
public SMSProviderResult sendSMS(String toPhone, String fromPhone, String message,String contactID, SendSMSParameters parameters)throws Exception {
CUSTOMSmsSettings smsSettings = new CUSTOMSmsSettings(); //Optional Custom Object to hold your Sms Provider Settings
SMSProviderResult result = new SMSProviderResult();
try
{
HashMap<String, Object> generalParameters = parameters.getGeneralParameters();
smsSettings.setUsername((String) generalParameters.get(ALIAS_USERNAME));
smsSettings.setPassword((String) generalParameters.get(ALIAS_PASSWORD));
smsSettings.setCommFrom((String) generalParameters.get(ALIAS_FROM));
if(fromPhone==null){
if(smsSettings.getCommFrom()!=null){
fromPhone=smsSettings.getCommFrom();
}else{
fromPhone="CRM.COM";
}
}
if(smsSettings.getCommFrom()==null){
smsSettings.setCommFrom(fromPhone);
}
//Implementation of the logic needed to communicate with SMS Provider and send the SMS
result.setStatus(SMSProviderResultStatus.COMPLETED);
}catch(ApiException e){
String request1 = new String("Information about the Request");
CallList.LogTextFile(getCRMSession(),request1,
"Providers/SMS Gateways/Errors/CUSTOM_SMS_GATEWAY", "");
CallList.LogTextFile(getCRMSession(), "Error:" + ((ApiException)e).getMoreInfo(),
"Providers/SMS Gateways/Errors/CUSTOM_SMS_GATEWAY", "");
result.setStatus(SMSProviderResultStatus.REJECTED);
if(e.getCode()!=null)
result.setErrorCode(e.getCode()+"");
result.setErrorDescription(e.getMoreInfo());
}catch(Exception e){
String request1 = new String("Information about the Request");
CallList.LogTextFile(getCRMSession(),request1,"Providers/SMS Gateways/Errors/CUSTOM_SMS_GATEWAY", "");
CallList.LogTextFile(getCRMSession(), "Error:" + ExceptionUtil.getStackTrace(e),"Providers/SMS Gateways/Errors/CUSTOM_SMS_GATEWAY", "");
result.setStatus(SMSProviderResultStatus.REJECTED);
result.setErrorCode("500");
result.setErrorDescription(e.getMessage());
}
return result;
}
@Override
public String getProtocol() throws Exception {
return PROVIDER_PROTOCOL;
}
@Override
public CRMDOSMSProvider setObjectsFromXML(CRMDOSMSProvider smsProvider) throws Exception {
// TODO Auto-generated method stub
return smsProvider;
}
/**
* Loads an effective sms provider
*
* @return an effective sms provider
* @throws Exception
*/
public CRMDOSMSProvider loadProvider() throws Exception {
CRMDOSMSProvider smsProvider = loadEffectiveProvider(getProtocol());
return smsProvider;
}
/**
* Loads an effective sms provider based on provider protocol
*
* @param protocol, sms provider protocol
* @return
* @throws Exception
*/
public CRMDOSMSProvider loadEffectiveProvider(String protocol) throws Exception
{
return loadEffectiveProvider(protocol, true);
}
/**
* Loads a effective provider based on provider protocol
*
* @param protocol sms provider protocol
* @param applicationServerFiltering - filter the provider based on application servers filtering configuration
* @return
* @throws Exception
*/
public CRMDOSMSProvider loadEffectiveProvider(String protocol , Boolean applicationServerFiltering) throws Exception {
CRMDOSMSProvider smsProvider = smsProviderBean.loadEffective(protocol,applicationServerFiltering);
if(smsProvider!=null)
{
smsProvider = setObjectsFromXML(smsProvider);
}
return smsProvider;
}
/**
* Loads a provider based on provider protocol
*
* @throws Exception
*/
public CRMDOSMSProvider loadProvider(String protocol) throws Exception
{
CRMDOSMSProvider smsProvider = smsProviderBean.loadByProtocol(protocol);
smsProvider = smsProviderBean.setObjectsFromXML(smsProvider);
return smsProvider;
}
}
|
...
1.Log in to CRM.COM
2.Go to / Settings & Admin / CRM Application / CRM Settings
3.On "Set up Communications" list click on (1)General Settings
...