Search in sources :

Example 1 with SriResponseValue

use of org.mobicents.smsc.library.SriResponseValue in project smscgateway by RestComm.

the class SriSbb method onSriFullResponse.

private void onSriFullResponse() {
    SendRoutingInfoForSMResponse sendRoutingInfoForSMResponse = this.getSendRoutingInfoForSMResponse();
    MAPErrorMessage errorMessage = this.getErrorResponse();
    SmsSet smsSet = getSmsSet();
    if (smsSet == null) {
        logger.severe("SriSbb.onSriFullResponse(): CMP smsSet is missed");
        markDeliveringIsEnded(true);
        return;
    }
    if (sendRoutingInfoForSMResponse != null) {
        // we have positive response to SRI request -
        // we will try to send messages
        // storing SRI response results into a cache firstly
        SriResponseValue sriResponseValue = new SriResponseValue(smsSet.getTargetId(), smsSet.getNetworkId(), smsSet.getDestAddr(), smsSet.getDestAddrTon(), smsSet.getDestAddrNpi(), sendRoutingInfoForSMResponse.getLocationInfoWithLMSI(), sendRoutingInfoForSMResponse.getIMSI().getData());
        try {
            SmsSetCache.getInstance().putSriResponseValue(sriResponseValue, smscPropertiesManagement.getSriResponseLiveTime());
        } catch (Exception e1) {
        // no actions in failure
        }
        executeForwardSM(smsSet, sendRoutingInfoForSMResponse.getLocationInfoWithLMSI(), sendRoutingInfoForSMResponse.getIMSI().getData(), smsSet.getNetworkId());
        return;
    }
    if (errorMessage != null) {
        // we have a negative response
        if (errorMessage.isEmAbsentSubscriber()) {
            this.onDeliveryError(smsSet, ErrorAction.mobileNotReachableFlag, ErrorCode.ABSENT_SUBSCRIBER, "AbsentSubscriber response from HLR: " + errorMessage.toString(), true, errorMessage, false, ProcessingType.SS7_SRI);
        } else if (errorMessage.isEmAbsentSubscriberSM()) {
            this.onDeliveryError(smsSet, ErrorAction.mobileNotReachableFlag, ErrorCode.ABSENT_SUBSCRIBER, "AbsentSubscriberSM response from HLR: " + errorMessage.toString(), true, errorMessage, false, ProcessingType.SS7_SRI);
        } else if (errorMessage.isEmCallBarred()) {
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.CALL_BARRED, "CallBarred response from HLR: " + errorMessage.toString(), true, errorMessage, false, ProcessingType.SS7_SRI);
        } else if (errorMessage.isEmFacilityNotSup()) {
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.FACILITY_NOT_SUPPORTED, "FacilityNotSuppored response from HLR: " + errorMessage.toString(), true, errorMessage, false, ProcessingType.SS7_SRI);
        } else if (errorMessage.isEmSystemFailure()) {
            // TODO: may be systemFailure is not a permanent error case ?
            this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SYSTEM_FAILURE, "SystemFailure response from HLR: " + errorMessage.toString(), true, errorMessage, false, ProcessingType.SS7_SRI);
        } else if (errorMessage.isEmUnknownSubscriber()) {
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.UNKNOWN_SUBSCRIBER, "UnknownSubscriber response from HLR: " + errorMessage.toString(), true, errorMessage, false, ProcessingType.SS7_SRI);
        } else if (errorMessage.isEmExtensionContainer()) {
            if (errorMessage.getEmExtensionContainer().getErrorCode() == MAPErrorCode.dataMissing) {
                this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.DATA_MISSING, "DataMissing response from HLR", true, errorMessage, false, ProcessingType.SS7_SRI);
            } else if (errorMessage.getEmExtensionContainer().getErrorCode() == MAPErrorCode.unexpectedDataValue) {
                this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.UNEXPECTED_DATA, "UnexpectedDataValue response from HLR", true, errorMessage, false, ProcessingType.SS7_SRI);
            } else if (errorMessage.getEmExtensionContainer().getErrorCode() == MAPErrorCode.teleserviceNotProvisioned) {
                this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.TELESERVICE_NOT_PROVISIONED, "TeleserviceNotProvisioned response from HLR", true, errorMessage, false, ProcessingType.SS7_SRI);
            } else {
                this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.UNEXPECTED_DATA_FROM_HLR, "Error response from HLR: " + errorMessage.toString(), true, errorMessage, false, ProcessingType.SS7_SRI);
            }
        } else {
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.UNEXPECTED_DATA_FROM_HLR, "Error response from HLR: " + errorMessage.toString(), true, errorMessage, false, ProcessingType.SS7_SRI);
        }
    } else {
        // we have no responses - this is an error behaviour
        this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.HLR_REJECT_AFTER_ROUTING_INFO, "Empty response after SRI Request", false, null, false, ProcessingType.SS7_SRI);
    }
}
Also used : SriResponseValue(org.mobicents.smsc.library.SriResponseValue) SendRoutingInfoForSMResponse(org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse) SmsSet(org.mobicents.smsc.library.SmsSet) MAPException(org.mobicents.protocols.ss7.map.api.MAPException) MAPErrorMessage(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)

Example 2 with SriResponseValue

use of org.mobicents.smsc.library.SriResponseValue in project smscgateway by RestComm.

the class SriSbb method onSms.

// *********
// initial event
public void onSms(SmsSetEvent event, ActivityContextInterface aci, EventContext eventContext) {
    SmsSet smsSet = event.getSmsSet();
    this.addInitialMessageSet(smsSet);
    try {
        if (this.logger.isFineEnabled()) {
            this.logger.fine("\nReceived Submit SMS. event= " + event + "this=" + this);
        }
        smscStatAggregator.updateMsgOutTryAll();
        smscStatAggregator.updateMsgOutTrySs7();
        if (smsSet.getDestAddrTon() == SmppConstants.TON_ALPHANUMERIC) {
            // bad TON at the destination address: alphanumerical is not supported
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.BAD_TYPE_OF_NUMBER, "TON \"alhpanumerical\" is not supported for as a destination address", true, null, false, ProcessingType.SS7_SRI);
            return;
        }
        if (smsSet.getDestAddrTon() != SmppConstants.TON_UNKNOWN && smsSet.getDestAddrTon() != SmppConstants.TON_INTERNATIONAL && smsSet.getDestAddrTon() != SmppConstants.TON_NATIONAL && smsSet.getDestAddrTon() != SmppConstants.TON_SUBSCRIBER) {
            // we support only following TON for a dest address
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.BAD_TYPE_OF_NUMBER, "TON " + smsSet.getDestAddrTon() + " is not supported for as a destination address", true, null, false, ProcessingType.SS7_SRI);
            return;
        }
        if (smsSet.getDestAddrNpi() != SmppConstants.NPI_UNKNOWN && smsSet.getDestAddrNpi() != SmppConstants.NPI_E164 && smsSet.getDestAddrNpi() != SmppConstants.NPI_X121 && smsSet.getDestAddrNpi() != SmppConstants.NPI_TELEX && smsSet.getDestAddrNpi() != SmppConstants.NPI_LAND_MOBILE) {
            // we support only following TON for a dest address
            this.onDeliveryError(smsSet, ErrorAction.permanentFailure, ErrorCode.BAD_NPI, "NPI " + smsSet.getDestAddrNpi() + " is not supported for as a destination address", true, null, false, ProcessingType.SS7_SRI);
            return;
        }
        Sms sms = this.obtainNextMessage(ProcessingType.SS7_SRI);
        if (sms == null) {
            // this means that no messages with good ScheduleDeliveryTime or
            // no messages at all we have to reschedule
            this.markDeliveringIsEnded(true);
            return;
        }
        // checking for correlationId - may be we do not need SRI
        String correlationID = smsSet.getCorrelationId();
        CorrelationIdValue civ = null;
        if (correlationID != null) {
            civ = SmsSetCache.getInstance().getCorrelationIdCacheElement(correlationID);
            if (this.logger.isFineEnabled()) {
                this.logger.fine("HomeRouting: correlationID=" + correlationID + ", found CorrelationIdValue=" + civ);
            }
        }
        if (civ != null && civ.getLocationInfoWithLMSI() != null && civ.getImsi() != null) {
            // preloaded routing info is found - skip SRI request
            MWStatus mwStatus = civ.getMwStatus();
            if (mwStatus != null) {
                InformServiceCenterContainer informServiceCenterContainer = new InformServiceCenterContainer();
                informServiceCenterContainer.setMwStatus(mwStatus);
                this.setInformServiceCenterContainer(informServiceCenterContainer);
            }
            this.setSriMapVersion(civ.getSriMapVersion());
            this.executeForwardSM(smsSet, civ.getLocationInfoWithLMSI(), civ.getImsi(), smsSet.getNetworkId());
            return;
        }
        // checking for cached - may be we do not need SRI
        String targetID = smsSet.getTargetId();
        SriResponseValue srv = null;
        srv = SmsSetCache.getInstance().getSriResponseValue(targetID);
        if (this.logger.isFineEnabled()) {
            this.logger.fine("SRI requesting: targetID=" + targetID + ", found cached SriResponseValue=" + srv);
        }
        if (srv != null) {
            // preloaded routing info is found - skip SRI request
            this.setSriMapVersion(3);
            this.executeForwardSM(smsSet, srv.getLocationInfoWithLMSI(), srv.getImsi(), smsSet.getNetworkId());
            return;
        }
        // no preloaded routing info
        this.sendSRI(smsSet, smsSet.getDestAddr(), smsSet.getDestAddrTon(), smsSet.getDestAddrNpi(), this.getSRIMAPApplicationContext(this.maxMAPApplicationContextVersion));
    } catch (Throwable e1) {
        String s = "Exception in SriSbb.onSms when fetching records and issuing events: " + e1.getMessage();
        logger.severe(s, e1);
        markDeliveringIsEnded(true);
    // this.onDeliveryError(smsSet, ErrorAction.temporaryFailure, ErrorCode.SC_SYSTEM_ERROR, s, true, null, false);
    }
}
Also used : InformServiceCenterContainer(org.mobicents.smsc.slee.services.smpp.server.events.InformServiceCenterContainer) MWStatus(org.mobicents.protocols.ss7.map.api.service.sms.MWStatus) SriResponseValue(org.mobicents.smsc.library.SriResponseValue) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) Sms(org.mobicents.smsc.library.Sms) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) CorrelationIdValue(org.mobicents.smsc.library.CorrelationIdValue) SmsSet(org.mobicents.smsc.library.SmsSet)

Aggregations

SmsSet (org.mobicents.smsc.library.SmsSet)2 SriResponseValue (org.mobicents.smsc.library.SriResponseValue)2 MAPException (org.mobicents.protocols.ss7.map.api.MAPException)1 MAPErrorMessage (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)1 AddressString (org.mobicents.protocols.ss7.map.api.primitives.AddressString)1 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)1 MAPDialogSms (org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms)1 MWStatus (org.mobicents.protocols.ss7.map.api.service.sms.MWStatus)1 SendRoutingInfoForSMResponse (org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse)1 CorrelationIdValue (org.mobicents.smsc.library.CorrelationIdValue)1 Sms (org.mobicents.smsc.library.Sms)1 InformServiceCenterContainer (org.mobicents.smsc.slee.services.smpp.server.events.InformServiceCenterContainer)1