Search in sources :

Example 26 with MAPApplicationContextVersion

use of org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion 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);
    }
}
Also used : ApplicationContextName(org.mobicents.protocols.ss7.tcap.asn.ApplicationContextName) MAPApplicationContextName(org.mobicents.protocols.ss7.map.api.MAPApplicationContextName) MAPRefuseReason(org.mobicents.protocols.ss7.map.api.dialog.MAPRefuseReason) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) MAPErrorCode(org.mobicents.protocols.ss7.map.api.errors.MAPErrorCode) ErrorCode(org.mobicents.smsc.library.ErrorCode) SmsSet(org.mobicents.smsc.library.SmsSet) MAPApplicationContext(org.mobicents.protocols.ss7.map.api.MAPApplicationContext) MAPApplicationContextVersion(org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion)

Aggregations

MAPApplicationContextVersion (org.mobicents.protocols.ss7.map.api.MAPApplicationContextVersion)22 SmsSet (org.mobicents.smsc.library.SmsSet)20 Test (org.testng.annotations.Test)20 ArrayList (java.util.ArrayList)19 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)18 ISDNAddressStringImpl (org.mobicents.protocols.ss7.map.primitives.ISDNAddressStringImpl)18 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)18 Sms (org.mobicents.smsc.library.Sms)18 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)18 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)18 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)18 IMSI (org.mobicents.protocols.ss7.map.api.primitives.IMSI)17 UUID (java.util.UUID)16 LocationInfoWithLMSI (org.mobicents.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI)16 SendRoutingInfoForSMResponse (org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse)16 IMSIImpl (org.mobicents.protocols.ss7.map.primitives.IMSIImpl)16 LocationInfoWithLMSIImpl (org.mobicents.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl)16 SendRoutingInfoForSMResponseImpl (org.mobicents.protocols.ss7.map.service.sms.SendRoutingInfoForSMResponseImpl)16 SmsProxy (org.mobicents.smsc.slee.resources.persistence.SmsProxy)16 MAPTestEvent (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy.MAPTestEvent)15