use of org.mobicents.smsc.library.ErrorCode in project smscgateway by RestComm.
the class MtSbb method setupMtForwardShortMessageRequest.
// *********
// Main service methods
public void setupMtForwardShortMessageRequest(ISDNAddressString networkNode, String imsiData, LMSI lmsi, int networkId) {
if (this.logger.isFineEnabled()) {
this.logger.fine("\nmperforming setupMtForwardShortMessageRequest ISDNAddressString= " + networkNode);
}
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
markDeliveringIsEnded(true);
logger.severe("MtSbb.setupMtForwardShortMessageRequest(): CMP smsSet is missed");
return;
}
Sms sms0 = smsSet.getSms(0);
Integer mtRemoteSccpTt = sms0.getMtRemoteSccpTt();
SccpAddress networkNodeSccpAddress = this.getMSCSccpAddress(networkNode, mtRemoteSccpTt);
IMSI imsi = this.mapParameterFactory.createIMSI(imsiData);
SM_RP_DA sm_RP_DA = this.mapParameterFactory.createSM_RP_DA(imsi);
AddressString scAddress = this.getServiceCenterAddressString(networkId);
SM_RP_OA sm_RP_OA = this.mapParameterFactory.createSM_RP_OA_ServiceCentreAddressOA(scAddress);
if (sms0 != null) {
// we only set it for first sms in the list
sms0.setMtServiceCenterAddress(scAddress.getAddress());
}
this.setNnn(networkNode);
this.setNetworkNode(networkNodeSccpAddress);
this.setSmRpDa(sm_RP_DA);
this.setSmRpOa(sm_RP_OA);
// Set cache with MAP version
MAPApplicationContextVersion mapApplicationContextVersion = mapVersionCache.getMAPApplicationContextVersion(networkNode.getAddress());
if (mapApplicationContextVersion == null) {
mapApplicationContextVersion = MAPApplicationContextVersion.getInstance(smscPropertiesManagement.getMaxMapVersion());
} else {
this.setNegotiatedMapVersionUsing(true);
}
this.setMAPVersionTested(mapApplicationContextVersion);
// dropaftersri mproc rules
try {
if (this.getTotalUnsentMessageCount() > 0) {
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
try {
synchronized (lock) {
this.applyMprocRulesOnImsiResponse(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNode, imsiData);
this.onImsiDrop(smsSet, lstPermFailured, lstRerouted, lstNewNetworkId, networkNode, imsiData);
}
} finally {
persistence.releaseSynchroObject(lock);
}
}
} catch (Throwable e) {
}
if (this.getTotalUnsentMessageCount() == 0) {
setupReportSMDeliveryStatusRequestSuccess(smsSet, true);
smsSet.setStatus(ErrorCode.SUCCESS);
this.markDeliveringIsEnded(true);
} else {
try {
this.sendMtSms(this.getMtFoSMSMAPApplicationContext(mapApplicationContextVersion), MessageProcessingState.firstMessageSending, null, smsSet.getNetworkId());
} catch (SmscProcessingException e) {
String reason = "SmscPocessingException when invoking sendMtSms() from setupMtForwardShortMessageRequest()-firstMessageSending: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
try {
smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
} catch (IllegalArgumentException e1) {
}
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
} catch (Throwable e) {
String reason = "Exception when invoking sendMtSms() from setupMtForwardShortMessageRequest()-firstMessageSending: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
}
}
}
use of org.mobicents.smsc.library.ErrorCode in project smscgateway by RestComm.
the class SriSbb method sendSRI.
// *********
// Main service methods
private void sendSRI(SmsSet smsSet, String destinationAddress, int ton, int npi, MAPApplicationContext mapApplicationContext) {
// Send out SRI
MAPDialogSms mapDialogSms = null;
try {
Sms sms0 = smsSet.getSms(0);
String mtLocalSccpGt = null;
Integer mtRemoteSccpTt = null;
if (sms0 != null) {
mtLocalSccpGt = sms0.getMtLocalSccpGt();
mtRemoteSccpTt = sms0.getMtRemoteSccpTt();
}
// 1. Create Dialog first and add the SRI request to it
mapDialogSms = this.setupRoutingInfoForSMRequestIndication(destinationAddress, ton, npi, mapApplicationContext, smsSet.getNetworkId(), mtLocalSccpGt, mtRemoteSccpTt);
// 2. Create the ACI and attach this SBB
ActivityContextInterface sriDialogACI = this.mapAcif.getActivityContextInterface(mapDialogSms);
sriDialogACI.attach(this.sbbContext.getSbbLocalObject());
// 3. Finally send the request
mapDialogSms.send();
} catch (MAPException e) {
if (mapDialogSms != null) {
mapDialogSms.release();
}
String reason = "MAPException when sending SRI from sendSRI(): " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_SRI);
}
}
use of org.mobicents.smsc.library.ErrorCode in project smscgateway by RestComm.
the class DeliveryCommonSbb method applyMProcPreDelivery.
private boolean applyMProcPreDelivery(Sms sms, ProcessingType processingType) {
MProcResult mProcResult = MProcManagement.getInstance().applyMProcPreDelivery(itsMProcRa, sms, processingType);
if (mProcResult.isMessageIsRerouted()) {
// firstly we check if rerouting attempts was not too many
if (sms.getReroutingCount() >= MAX_POSSIBLE_REROUTING) {
StringBuilder sb = new StringBuilder();
sb.append("Rerouting message attempt in PreDelivery, but we have already rerouted ");
sb.append(MAX_POSSIBLE_REROUTING);
sb.append(" times before: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", newNetworkId=");
sb.append(mProcResult.getNewNetworkId());
sb.append(", sms=");
sb.append(sms);
this.logger.warning(sb.toString());
return false;
} else if (mProcResult.getNewNetworkId() == sms.getSmsSet().getNetworkId()) {
// we do not reroute for the same networkId
return true;
} else {
ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
lstRerouted.add(sms);
lstNewNetworkId.add(mProcResult.getNewNetworkId());
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Rerouting message in PreDelivery: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", newNetworkId=");
sb.append(mProcResult.getNewNetworkId());
sb.append(", sms=");
sb.append(sms);
this.logger.info(sb.toString());
}
postProcessRerouted(lstRerouted, lstNewNetworkId);
return false;
}
} else if (mProcResult.isMessageDropped()) {
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Dropping message after in PreDelivery: targetId=");
sb.append(sms.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(sms);
this.logger.info(sb.toString());
}
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
lstPermFailured.add(sms);
ErrorCode smStatus = ErrorCode.MPROC_PRE_DELIVERY_DROP;
ErrorAction errorAction = ErrorAction.permanentFailure;
String reason = "Message drop in PreDelivery";
sms.getSmsSet().setStatus(smStatus);
// sending of a failure response for transactional mode
this.sendTransactionalResponseFailure(lstPermFailured, null, errorAction, null);
// Processing messages that were temp or permanent failed or rerouted
this.postProcessPermFailures(lstPermFailured, null, null);
// generating CDRs for permanent failure messages
this.generateCDRs(lstPermFailured, CdrGenerator.CDR_MPROC_DROP_PRE_DELIVERY, reason);
EsmeManagement esmeManagement = EsmeManagement.getInstance();
Esme esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
String messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
this.generateDetailedCDRs(lstPermFailured, EventType.OUT_SMPP_ERROR, smStatus, messageType, esme.getRemoteAddressAndPort(), -1);
// sending of failure delivery receipts
this.generateFailureReceipts(sms.getSmsSet(), lstPermFailured, null);
return false;
}
FastList<Sms> addedMessages = mProcResult.getMessageList();
if (addedMessages != null) {
for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
Sms smst = n.getValue();
TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
this.sendNewGeneratedMessage(smst, ta);
if (this.logger.isInfoEnabled()) {
StringBuilder sb = new StringBuilder();
sb.append("Posting of a new message after PreDelivery: targetId=");
sb.append(smst.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(smst);
this.logger.info(sb.toString());
}
}
}
return true;
}
use of org.mobicents.smsc.library.ErrorCode in project smscgateway by RestComm.
the class DeliveryCommonSbb method endDeliveryAfterValidityPeriod.
/**
* Finishing delivering of a message which validity period is over at the start of delivery time.
*
* @param sms
* @param processingType
* @param dlvMessageId
* @param dlvDestId
*/
protected void endDeliveryAfterValidityPeriod(Sms sms, ProcessingType processingType, String dlvMessageId, String dlvDestId) {
// ending of delivery process in this SBB
ErrorCode smStatus = ErrorCode.VALIDITY_PERIOD_EXPIRED;
ErrorAction errorAction = ErrorAction.permanentFailure;
String reason = "Validity period is expired";
smsSet.setStatus(smStatus);
StringBuilder sb = new StringBuilder();
sb.append("onDeliveryError: errorAction=validityExpired");
sb.append(", smStatus=");
sb.append(smStatus);
sb.append(", targetId=");
sb.append(smsSet.getTargetId());
sb.append(", smsSet=");
sb.append(smsSet);
sb.append(", reason=");
sb.append(reason);
if (this.logger.isInfoEnabled())
this.logger.info(sb.toString());
// mproc rules applying for delivery phase
MProcResult mProcResult = MProcManagement.getInstance().applyMProcDelivery(itsMProcRa, sms, true, processingType);
if (mProcResult.isMessageIsRerouted()) {
// we do not reroute a message with expired validity period
sb = new StringBuilder();
sb.append("Can not reroute of a message with expired ValidityPeriod, sms=");
sb.append(sms);
this.logger.warning(sb.toString());
}
FastList<Sms> addedMessages = mProcResult.getMessageList();
if (addedMessages != null) {
for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
Sms smst = n.getValue();
TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
this.sendNewGeneratedMessage(smst, ta);
if (this.logger.isInfoEnabled()) {
sb = new StringBuilder();
sb.append("Posting of a new message after PermFailure-ValidityPeriod: targetId=");
sb.append(smst.getSmsSet().getTargetId());
sb.append(", sms=");
sb.append(smst);
this.logger.info(sb.toString());
}
}
}
ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
lstPermFailured.add(sms);
// sending of a failure response for transactional mode
this.sendTransactionalResponseFailure(lstPermFailured, null, errorAction, null);
// Processing messages that were temp or permanent failed or rerouted
this.postProcessPermFailures(lstPermFailured, dlvMessageId, dlvDestId);
// generating CDRs for permanent failure messages
this.generateCDRs(lstPermFailured, CdrGenerator.CDR_FAILED, reason);
EsmeManagement esmeManagement = EsmeManagement.getInstance();
if (esmeManagement != null) {
Esme esme = null;
if (smsSet.getDestClusterName() != null) {
esme = esmeManagement.getEsmeByClusterName(smsSet.getDestClusterName());
}
String messageType = null;
String remoteAddr = null;
if (esme != null) {
messageType = esme.getSmppSessionType() == Type.CLIENT ? CdrDetailedGenerator.CDR_MSG_TYPE_SUBMITSM : CdrDetailedGenerator.CDR_MSG_TYPE_DELIVERSM;
remoteAddr = esme.getRemoteAddressAndPort();
}
this.generateDetailedCDRs(lstPermFailured, EventType.VALIDITY_PERIOD_TIMEOUT, smStatus, messageType, remoteAddr, -1);
}
// sending of failure delivery receipts
this.generateFailureReceipts(smsSet, lstPermFailured, null);
}
use of org.mobicents.smsc.library.ErrorCode in project smscgateway by RestComm.
the class MtSbb method onDialogReject.
@Override
public void onDialogReject(DialogReject evt, ActivityContextInterface aci) {
try {
SmsSet smsSet = getSmsSet();
if (smsSet == null) {
logger.severe("MtSbb.onDialogReject(): CMP smsSet is missed");
markDeliveringIsEnded(true);
return;
}
MAPRefuseReason mapRefuseReason = evt.getRefuseReason();
if (mapRefuseReason == MAPRefuseReason.PotentialVersionIncompatibility && evt.getMAPDialog().getApplicationContext().getApplicationContextVersion() != MAPApplicationContextVersion.version1) {
if (logger.isWarningEnabled()) {
this.logger.warning("Rx : Mt onDialogReject / PotentialVersionIncompatibility=" + evt);
}
MAPApplicationContextVersion newMAPApplicationContextVersion = MAPApplicationContextVersion.version1;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
// If version1 already tried this is error
String reason = "Error condition when invoking sendMtSms() from onDialogReject()." + newMAPApplicationContextVersion + " already tried and DialogReject again suggests Version1";
this.logger.severe(reason);
ErrorCode smStatus = ErrorCode.MAP_SERVER_VERSION_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
this.setNegotiatedMapVersionUsing(false);
this.setMAPVersionTested(newMAPApplicationContextVersion);
mapVersionCache.setMAPApplicationContextVersion(this.getNetworkNode().getGlobalTitle().getDigits(), newMAPApplicationContextVersion);
// Now send new ForwardSM with supported ACN (MAP V1)
try {
// Update cache
this.sendMtSms(this.getMtFoSMSMAPApplicationContext(MAPApplicationContextVersion.version1), MessageProcessingState.resendAfterMapProtocolNegotiation, null, smsSet.getNetworkId());
return;
} catch (SmscProcessingException e) {
String reason = "SmscPocessingException when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
try {
smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
} catch (IllegalArgumentException e1) {
}
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
} catch (Throwable e) {
String reason = "Exception when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
}
// If ACN not supported, lets use the new one suggested
if (mapRefuseReason == MAPRefuseReason.ApplicationContextNotSupported) {
String nodeDigits = this.getNetworkNode().getGlobalTitle().getDigits();
if (logger.isWarningEnabled()) {
this.logger.warning("Rx : Mt onDialogReject / ApplicationContextNotSupported for node " + nodeDigits + " Event=" + evt);
}
// Now send new MtSMS with supported ACN
ApplicationContextName tcapApplicationContextName = evt.getAlternativeApplicationContext();
MAPApplicationContext supportedMAPApplicationContext = MAPApplicationContext.getInstance(tcapApplicationContextName.getOid());
MAPApplicationContextVersion supportedMAPApplicationContextVersion = supportedMAPApplicationContext.getApplicationContextVersion();
MAPApplicationContextVersion newMAPApplicationContextVersion = supportedMAPApplicationContextVersion;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
newMAPApplicationContextVersion = MAPApplicationContextVersion.version3;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
newMAPApplicationContextVersion = MAPApplicationContextVersion.version2;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
newMAPApplicationContextVersion = MAPApplicationContextVersion.version1;
if (this.isMAPVersionTested(newMAPApplicationContextVersion)) {
// If all versions are already tried this is
// error
String reason = "Error condition when invoking sendMtSms() from onDialogReject()." + " all MAP versions are already tried and DialogReject again suggests Version1";
this.logger.severe(reason);
ErrorCode smStatus = ErrorCode.MAP_SERVER_VERSION_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
}
}
}
this.setNegotiatedMapVersionUsing(false);
this.setMAPVersionTested(newMAPApplicationContextVersion);
mapVersionCache.setMAPApplicationContextVersion(this.getNetworkNode().getGlobalTitle().getDigits(), newMAPApplicationContextVersion);
try {
this.sendMtSms(this.getMtFoSMSMAPApplicationContext(newMAPApplicationContextVersion), MessageProcessingState.resendAfterMapProtocolNegotiation, null, smsSet.getNetworkId());
return;
} catch (SmscProcessingException e) {
String reason = "SmscPocessingException when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
try {
smStatus = ErrorCode.fromInt(e.getSmppErrorCode());
} catch (IllegalArgumentException e1) {
}
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
} catch (Throwable e) {
String reason = "Exception when invoking sendMtSms() from onDialogReject()-resendAfterMapProtocolNegotiation: " + e.toString();
this.logger.severe(reason, e);
ErrorCode smStatus = ErrorCode.SC_SYSTEM_ERROR;
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, smStatus, reason, true, null, false, ProcessingType.SS7_MT);
return;
}
}
super.onDialogReject(evt, aci);
this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.MSC_REFUSES_SM, "onDialogReject after MT Request: " + mapRefuseReason != null ? mapRefuseReason.toString() : "", true, null, false, ProcessingType.SS7_MT);
} catch (Throwable e1) {
logger.severe("Exception in MtSbb.onDialogReject() when fetching records and issuing events: " + e1.getMessage(), e1);
markDeliveringIsEnded(true);
}
}
Aggregations