Search in sources :

Example 11 with MAPDialogSms

use of org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms in project smscgateway by RestComm.

the class MoSbb method onForwardShortMessageRequest.

public void onForwardShortMessageRequest(ForwardShortMessageRequest evt, ActivityContextInterface aci) {
    if (this.logger.isFineEnabled()) {
        this.logger.fine("Received FORWARD_SHORT_MESSAGE_REQUEST = " + evt);
    }
    MAPDialogSms dialog = evt.getMAPDialog();
    // checking if it is MO or MT
    boolean isMt;
    MAPApplicationContext act = dialog.getApplicationContext();
    if (act.getApplicationContextVersion().getVersion() > 1) {
        if (act.getApplicationContextName() == MAPApplicationContextName.shortMsgMORelayContext)
            isMt = false;
        else
            isMt = true;
    } else {
        if (evt.getSM_RP_OA().getMsisdn() != null)
            isMt = false;
        else
            isMt = true;
    }
    this.setProcessingState(MoProcessingState.OtherDataRecieved);
    MoChargingType charging;
    if (isMt) {
        charging = smscPropertiesManagement.getHrCharging();
    } else {
        charging = smscPropertiesManagement.getMoCharging();
    }
    if (charging == MoChargingType.reject) {
        try {
            MAPErrorMessage errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageFacilityNotSup(null, null, null);
            dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
            if (this.logger.isInfoEnabled()) {
                this.logger.info("\nSent ErrorComponent = " + errorMessage);
            }
            this.logger.warning("************* 0001");
            if (smscPropertiesManagement.isGenerateRejectionCdr()) {
                this.logger.warning("************* 0002");
                generateCDR(dialog.getNetworkId(), null, dialog.getLocalAddress(), isMt ? CdrGenerator.CDR_SUBMIT_FAILED_HR : CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
                this.logger.warning("************* 0003");
            }
            dialog.close(false);
            return;
        } catch (Throwable e) {
            logger.severe("Error while sending Error message", e);
            return;
        }
    }
    Sms sms = null;
    try {
        String originatorSccpAddress = null;
        SccpAddress sccpAddress = dialog.getRemoteAddress();
        if (sccpAddress != null) {
            GlobalTitle gt = dialog.getRemoteAddress().getGlobalTitle();
            if (gt != null)
                originatorSccpAddress = gt.getDigits();
        }
        if (isMt) {
            sms = this.processMtMessage(evt.getSM_RP_OA(), evt.getSM_RP_DA(), evt.getSM_RP_UI(), dialog.getNetworkId(), originatorSccpAddress, false, evt.getMAPDialog(), evt, evt.getInvokeId());
        } else {
            sms = this.processMoMessage(evt.getSM_RP_OA(), evt.getSM_RP_DA(), evt.getSM_RP_UI(), dialog.getNetworkId(), originatorSccpAddress, false, evt.getMAPDialog(), evt, evt.getInvokeId());
        }
        if (sms != null) {
            this.processSms(sms, persistence, charging, !isMt, dialog, evt, evt.getInvokeId());
        }
    } catch (SmscProcessingException e1) {
        if (!e1.isSkipErrorLogging()) {
            if (e1.isIsWarning()) {
                this.logger.warning(e1.getMessage());
            } else {
                this.logger.severe(e1.getMessage(), e1);
            }
            smscStatAggregator.updateMsgInFailedAll();
        }
        try {
            MAPErrorMessage errorMessage;
            switch(e1.getMapErrorCode()) {
                case MAPErrorCode.unexpectedDataValue:
                    errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageExtensionContainer((long) MAPErrorCode.unexpectedDataValue, null);
                    break;
                case MAPErrorCode.systemFailure:
                    errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
                    break;
                case MAPErrorCode.resourceLimitation:
                    errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageExtensionContainer((long) MAPErrorCode.resourceLimitation, null);
                    break;
                case MAPErrorCode.facilityNotSupported:
                    errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageFacilityNotSup(null, null, null);
                    break;
                default:
                    errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
                    break;
            }
            if (smscPropertiesManagement.isGenerateRejectionCdr() && !e1.isMessageRejectCdrCreated()) {
                if (sms != null) {
                    generateCDR(sms, isMt ? CdrGenerator.CDR_SUBMIT_FAILED_HR : CdrGenerator.CDR_SUBMIT_FAILED_MO, e1.getMessage(), false, true);
                } else {
                    generateCDR(dialog.getNetworkId(), null, dialog.getLocalAddress(), isMt ? CdrGenerator.CDR_SUBMIT_FAILED_HR : CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
                }
            }
            dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
            if (this.logger.isInfoEnabled()) {
                this.logger.info("\nSent ErrorComponent = " + errorMessage);
            }
            dialog.close(false);
        } catch (Throwable e) {
            logger.severe("Error while sending Error message", e);
            return;
        }
        return;
    } catch (Throwable e1) {
        this.logger.severe("Exception while processing MO message: " + e1.getMessage(), e1);
        smscStatAggregator.updateMsgInFailedAll();
        try {
            MAPErrorMessage errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
            if (smscPropertiesManagement.isGenerateRejectionCdr()) {
                generateCDR(dialog.getNetworkId(), null, dialog.getLocalAddress(), isMt ? CdrGenerator.CDR_SUBMIT_FAILED_HR : CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
            }
            dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
            dialog.close(false);
        } catch (Throwable e) {
            logger.severe("Error while sending Error message", e);
            return;
        }
        return;
    }
    if (sms == null || sms.getMessageDeliveryResultResponse() == null) {
        try {
            dialog.addForwardShortMessageResponse(evt.getInvokeId());
            if (this.logger.isFineEnabled()) {
                this.logger.fine("\nSent ForwardShortMessageResponse = " + evt);
            }
            dialog.close(false);
        } catch (Throwable e) {
            logger.severe("Error while sending ForwardShortMessageResponse ", e);
        }
    }
}
Also used : SccpAddress(org.mobicents.protocols.ss7.sccp.parameter.SccpAddress) MoChargingType(org.mobicents.smsc.domain.MoChargingType) GlobalTitle(org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) MAPApplicationContext(org.mobicents.protocols.ss7.map.api.MAPApplicationContext) MAPErrorMessage(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)

Example 12 with MAPDialogSms

use of org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms in project smscgateway by RestComm.

the class MoSbb method processMtMessage.

// *********
// incoming message processing
private Sms processMtMessage(SM_RP_OA smRPOA, SM_RP_DA smRPDA, SmsSignalInfo smsSignalInfo, int networkId, String originatorSccpAddress, boolean isMoOperation, MAPDialogSms dialog, SmsMessage evt, long invokeId) throws SmscProcessingException {
    Sms sms = null;
    smsSignalInfo.setGsm8Charset(isoCharset);
    IMSI destinationImsi = smRPDA.getIMSI();
    if (destinationImsi == null) {
        throw new SmscProcessingException("Home routing: Mt DA IMSI is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    // obtaining correlationId
    String correlationID = destinationImsi.getData();
    CorrelationIdValue civ;
    try {
        civ = SmsSetCache.getInstance().getCorrelationIdCacheElement(correlationID);
    } catch (Exception e) {
        throw new SmscProcessingException("Home routing: Error when getting of CorrelationIdCacheElement", SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
    }
    if (civ == null) {
        smscStatAggregator.updateHomeRoutingCorrIdFail();
        throw new SmscProcessingException("Home routing: No data is found for: CorrelationId=" + correlationID, SmppConstants.STATUS_SYSERR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    SmsTpdu smsTpdu = null;
    try {
        smsTpdu = smsSignalInfo.decodeTpdu(false);
        logger.fine("Home routing: The SmsTpduType is " + smsTpdu.getSmsTpduType());
        switch(smsTpdu.getSmsTpduType()) {
            case SMS_DELIVER:
                SmsDeliverTpdu smsDeliverTpdu = (SmsDeliverTpdu) smsTpdu;
                if (this.logger.isInfoEnabled()) {
                    this.logger.info("Home routing: Received SMS_DELIVER = " + smsDeliverTpdu);
                }
                // AddressField af = smsSubmitTpdu.getDestinationAddress();
                sms = this.handleSmsDeliverTpdu(smsDeliverTpdu, civ, networkId, originatorSccpAddress, isMoOperation, dialog, evt, invokeId);
                break;
            default:
                this.logger.severe("Home routing: Received non SMS_DELIVER = " + smsTpdu);
                break;
        }
    } catch (MAPException e1) {
        logger.severe("Home routing: Error while decoding SmsSignalInfo ", e1);
    }
    return sms;
}
Also used : SmsDeliverTpdu(org.mobicents.protocols.ss7.map.api.smstpdu.SmsDeliverTpdu) MAPException(org.mobicents.protocols.ss7.map.api.MAPException) SmsTpdu(org.mobicents.protocols.ss7.map.api.smstpdu.SmsTpdu) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) IMSI(org.mobicents.protocols.ss7.map.api.primitives.IMSI) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) MAPException(org.mobicents.protocols.ss7.map.api.MAPException)

Example 13 with MAPDialogSms

use of org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms in project smscgateway by RestComm.

the class MoSbb method onMoForwardShortMessageRequest.

// *********
// SMS Event Handlers
/**
 * Received incoming SMS for ACN v3. Send back ack
 *
 * @param evt
 * @param aci
 */
public void onMoForwardShortMessageRequest(MoForwardShortMessageRequest evt, ActivityContextInterface aci) {
    if (this.logger.isFineEnabled()) {
        this.logger.fine("\nReceived MO_FORWARD_SHORT_MESSAGE_REQUEST = " + evt);
    }
    this.setProcessingState(MoProcessingState.OtherDataRecieved);
    MAPDialogSms dialog = evt.getMAPDialog();
    if (smscPropertiesManagement.getMoCharging() == MoChargingType.reject) {
        try {
            MAPErrorMessage errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageFacilityNotSup(null, null, null);
            dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
            if (this.logger.isInfoEnabled()) {
                this.logger.info("\nSent ErrorComponent = " + errorMessage);
            }
            if (smscPropertiesManagement.isGenerateRejectionCdr()) {
                String imsiData = null;
                if (evt.getIMSI() != null) {
                    imsiData = evt.getIMSI().getData();
                }
                generateCDR(dialog.getNetworkId(), imsiData, dialog.getLocalAddress(), CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
            }
            dialog.close(false);
            return;
        } catch (Throwable e) {
            logger.severe("Error while sending Error message", e);
            return;
        }
    }
    Sms sms = null;
    try {
        String originatorSccpAddress = null;
        SccpAddress sccpAddress = dialog.getRemoteAddress();
        if (sccpAddress != null) {
            GlobalTitle gt = sccpAddress.getGlobalTitle();
            if (gt != null)
                originatorSccpAddress = gt.getDigits();
        }
        sms = this.processMoMessage(evt.getSM_RP_OA(), evt.getSM_RP_DA(), evt.getSM_RP_UI(), dialog.getNetworkId(), originatorSccpAddress, true, evt.getMAPDialog(), evt, evt.getInvokeId());
        if (sms != null) {
            this.processSms(sms, persistence, smscPropertiesManagement.getMoCharging(), true, dialog, evt, evt.getInvokeId());
        }
    } catch (SmscProcessingException e1) {
        if (!e1.isSkipErrorLogging()) {
            if (e1.isIsWarning()) {
                this.logger.warning(e1.getMessage());
            } else {
                this.logger.severe(e1.getMessage(), e1);
            }
            smscStatAggregator.updateMsgInFailedAll();
        }
        try {
            MAPErrorMessage errorMessage;
            switch(e1.getMapErrorCode()) {
                case MAPErrorCode.unexpectedDataValue:
                    errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageExtensionContainer((long) MAPErrorCode.unexpectedDataValue, null);
                    break;
                case MAPErrorCode.systemFailure:
                    errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
                    break;
                case MAPErrorCode.resourceLimitation:
                    errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageExtensionContainer((long) MAPErrorCode.resourceLimitation, null);
                    break;
                case MAPErrorCode.facilityNotSupported:
                    errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageFacilityNotSup(null, null, null);
                    break;
                default:
                    errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
                    break;
            }
            dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
            if (this.logger.isInfoEnabled()) {
                this.logger.info("\nSent ErrorComponent = " + errorMessage);
            }
            if (smscPropertiesManagement.isGenerateRejectionCdr() && !e1.isMessageRejectCdrCreated()) {
                if (sms != null) {
                    generateCDR(sms, CdrGenerator.CDR_SUBMIT_FAILED_MO, e1.getMessage(), false, true);
                } else {
                    generateCDR(dialog.getNetworkId(), evt.getIMSI().getData(), dialog.getLocalAddress(), CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
                }
            }
            dialog.close(false);
        } catch (Throwable e) {
            logger.severe("Error while sending Error message", e);
            return;
        }
        return;
    } catch (Throwable e1) {
        this.logger.severe("Exception while processing MO message: " + e1.getMessage(), e1);
        smscStatAggregator.updateMsgInFailedAll();
        try {
            MAPErrorMessage errorMessage = this.mapProvider.getMAPErrorMessageFactory().createMAPErrorMessageSystemFailure(dialog.getApplicationContext().getApplicationContextVersion().getVersion(), null, null, null);
            dialog.sendErrorComponent(evt.getInvokeId(), errorMessage);
            if (smscPropertiesManagement.isGenerateRejectionCdr()) {
                generateCDR(dialog.getNetworkId(), evt.getIMSI().getData(), dialog.getLocalAddress(), CdrGenerator.CDR_SUBMIT_FAILED_MO, errorMessage.toString(), true);
            }
            dialog.close(false);
        } catch (Throwable e) {
            logger.severe("Error while sending Error message", e);
            return;
        }
        return;
    }
    if (sms == null || sms.getMessageDeliveryResultResponse() == null) {
        try {
            dialog.addMoForwardShortMessageResponse(evt.getInvokeId(), null, null);
            if (this.logger.isFineEnabled()) {
                this.logger.fine("\nSent MoForwardShortMessageResponse = " + evt);
            }
            dialog.close(false);
        } catch (Throwable e) {
            logger.severe("Error while sending MoForwardShortMessageResponse ", e);
        }
    }
}
Also used : SccpAddress(org.mobicents.protocols.ss7.sccp.parameter.SccpAddress) GlobalTitle(org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) MAPErrorMessage(org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)

Example 14 with MAPDialogSms

use of org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms in project smscgateway by RestComm.

the class HrSriServerSbb method doSendResponse.

private void doSendResponse(CorrelationIdValue correlationIdValue, MAPDialogSms dlg, String imsiValue, LocationInfoWithLMSI li) throws MAPException {
    long invokeId = this.getInvokeId();
    IMSI imsi = this.mapParameterFactory.createIMSI(imsiValue);
    MWStatus mwStatus = correlationIdValue.getMwStatus();
    Boolean mwdSet = null;
    if (dlg.getApplicationContext().getApplicationContextVersion() == MAPApplicationContextVersion.version1) {
        if (mwStatus != null) {
            if (mwStatus.getMnrfSet())
                mwdSet = true;
            mwStatus = null;
        }
    }
    dlg.addSendRoutingInfoForSMResponse(invokeId, imsi, li, null, mwdSet);
    InformServiceCentreRequest isc = correlationIdValue.getInformServiceCentreRequest();
    if (mwStatus != null && isc != null) {
        dlg.addInformServiceCentreRequest(isc.getStoredMSISDN(), isc.getMwStatus(), null, isc.getAbsentSubscriberDiagnosticSM(), isc.getAdditionalAbsentSubscriberDiagnosticSM());
    }
    dlg.close(false);
}
Also used : MWStatus(org.mobicents.protocols.ss7.map.api.service.sms.MWStatus) InformServiceCentreRequest(org.mobicents.protocols.ss7.map.api.service.sms.InformServiceCentreRequest) IMSI(org.mobicents.protocols.ss7.map.api.primitives.IMSI)

Example 15 with MAPDialogSms

use of org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms in project smscgateway by RestComm.

the class HrSriServerSbb method onSriHrByPass.

@Override
public void onSriHrByPass(CorrelationIdValue correlationIdValue) {
    MAPDialogSms dlg = this.getActivity();
    if (dlg == null) {
        this.logger.severe("Home routing: can not get MAPDialog for sending SRI hrByPass Response");
        return;
    }
    smscStatAggregator.updateMsgInHrSriHrByPass();
    StringBuilder sb = new StringBuilder();
    sb.append("Home routing: bypassing of Home routing: procedure: transaction: ");
    sb.append(correlationIdValue);
    if (this.logger.isInfoEnabled())
        this.logger.info(sb.toString());
    // sending original SRI response
    try {
        SendRoutingInfoForSMResponse sendRoutingInfoForSMResponse = correlationIdValue.getSendRoutingInfoForSMResponse();
        this.doSendResponse(correlationIdValue, dlg, sendRoutingInfoForSMResponse.getIMSI().getData(), sendRoutingInfoForSMResponse.getLocationInfoWithLMSI());
    } catch (MAPException e) {
        if (dlg != null) {
            dlg.release();
        }
        String reason = "Home routing: MAPException when sending SRI bypassing of Home routing: " + e.toString();
        this.logger.severe(reason, e);
    }
}
Also used : MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) MAPException(org.mobicents.protocols.ss7.map.api.MAPException) ISDNAddressString(org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.mobicents.protocols.ss7.map.api.primitives.AddressString) SendRoutingInfoForSMResponse(org.mobicents.protocols.ss7.map.api.service.sms.SendRoutingInfoForSMResponse)

Aggregations

MAPDialogSms (org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms)25 MAPException (org.mobicents.protocols.ss7.map.api.MAPException)17 ISDNAddressString (org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString)16 AddressString (org.mobicents.protocols.ss7.map.api.primitives.AddressString)14 SccpAddress (org.mobicents.protocols.ss7.sccp.parameter.SccpAddress)8 MAPErrorMessage (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessage)6 ActivityContextInterface (javax.slee.ActivityContextInterface)4 SmsSignalInfo (org.mobicents.protocols.ss7.map.api.service.sms.SmsSignalInfo)4 IMSI (org.mobicents.protocols.ss7.map.api.primitives.IMSI)3 SM_RP_DA (org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_DA)3 SmsTpdu (org.mobicents.protocols.ss7.map.api.smstpdu.SmsTpdu)3 GlobalTitle (org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle)3 Sms (org.mobicents.smsc.library.Sms)3 SmsSet (org.mobicents.smsc.library.SmsSet)3 MAPApplicationContext (org.mobicents.protocols.ss7.map.api.MAPApplicationContext)2 MAPErrorMessageSubscriberBusyForMtSms (org.mobicents.protocols.ss7.map.api.errors.MAPErrorMessageSubscriberBusyForMtSms)2 LocationInfoWithLMSI (org.mobicents.protocols.ss7.map.api.service.sms.LocationInfoWithLMSI)2 SM_RP_OA (org.mobicents.protocols.ss7.map.api.service.sms.SM_RP_OA)2 SmsSubmitTpdu (org.mobicents.protocols.ss7.map.api.smstpdu.SmsSubmitTpdu)2 SmscProcessingException (org.mobicents.smsc.library.SmscProcessingException)2