Search in sources :

Example 11 with MAPException

use of org.mobicents.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.

the class MAPDialogSmsProxy method addSendRoutingInfoForSMRequest.

@Override
public Long addSendRoutingInfoForSMRequest(ISDNAddressString msisdn, boolean sm_RP_PRI, AddressString serviceCentreAddress, MAPExtensionContainer extensionContainer, boolean gprsSupportIndicator, SM_RP_MTI sM_RP_MTI, SM_RP_SMEA sM_RP_SMEA, TeleserviceCode teleservice) throws MAPException {
    SendRoutingInfoForSMRequestImpl msg = new SendRoutingInfoForSMRequestImpl(msisdn, sm_RP_PRI, serviceCentreAddress, extensionContainer, gprsSupportIndicator, sM_RP_MTI, sM_RP_SMEA, teleservice);
    this.eventList.add(new MAPTestEvent(MAPTestEventType.componentAdded, msg));
    return 0L;
}
Also used : SendRoutingInfoForSMRequestImpl(org.mobicents.protocols.ss7.map.service.sms.SendRoutingInfoForSMRequestImpl)

Example 12 with MAPException

use of org.mobicents.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.

the class RsdsSbb method setupReportSMDeliveryStatusRequest.

// *********
// Main service methods
public void setupReportSMDeliveryStatusRequest(ISDNAddressString msisdn, AddressString serviceCentreAddress, SMDeliveryOutcome smDeliveryOutcome, SccpAddress destAddress, MAPApplicationContext mapApplicationContext, String targetId, int networkId, String mtLocalSccpGt) {
    if (this.logger.isInfoEnabled()) {
        this.logger.info("Received setupReportSMDeliveryStatus request msisdn= " + msisdn + ", serviceCentreAddress=" + serviceCentreAddress + ", sMDeliveryOutcome=" + smDeliveryOutcome + ", mapApplicationContext=" + mapApplicationContext);
    }
    this.setTargetId(targetId);
    this.setSmDeliveryOutcome(smDeliveryOutcome);
    MAPDialogSms mapDialogSms;
    try {
        SccpAddress originSccpAddress;
        if (mtLocalSccpGt != null) {
            originSccpAddress = this.getServiceCenterSccpAddress(mtLocalSccpGt, networkId);
        } else {
            originSccpAddress = this.getServiceCenterSccpAddress(networkId);
        }
        mapDialogSms = this.mapProvider.getMAPServiceSms().createNewDialog(mapApplicationContext, originSccpAddress, null, destAddress, null);
        mapDialogSms.setNetworkId(networkId);
        ActivityContextInterface mtFOSmsDialogACI = this.mapAcif.getActivityContextInterface(mapDialogSms);
        mtFOSmsDialogACI.attach(this.sbbContext.getSbbLocalObject());
        mapDialogSms.addReportSMDeliveryStatusRequest(msisdn, serviceCentreAddress, smDeliveryOutcome, null, null, false, false, null, null);
        if (this.logger.isInfoEnabled())
            this.logger.info("Sending: ReportSMDeliveryStatusRequest: msisdn=" + msisdn + ", serviceCenterAddress=" + serviceCentreAddress + ", smDeliveryOutcome=" + smDeliveryOutcome);
        mapDialogSms.send();
    } catch (MAPException e) {
        this.logger.severe("MAPException when sending reportSMDeliveryStatusRequest: " + e.getMessage(), e);
    }
}
Also used : SccpAddress(org.restcomm.protocols.ss7.sccp.parameter.SccpAddress) MAPDialogSms(org.restcomm.protocols.ss7.map.api.service.sms.MAPDialogSms) ActivityContextInterface(javax.slee.ActivityContextInterface) MAPException(org.restcomm.protocols.ss7.map.api.MAPException)

Example 13 with MAPException

use of org.mobicents.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.

the class MoSbb method processMoMessage.

private Sms processMoMessage(SM_RP_OA smRPOA, SM_RP_DA smRPDA, SmsSignalInfo smsSignalInfo, int networkId, String originatorSccpAddress, boolean isMoOperation, MAPDialogSms dialog, SmsMessage evt, long invokeId) throws SmscProcessingException {
    // TODO: check if smRPDA contains local SMSC address and reject messages
    // if not equal ???
    Sms sms = null;
    smsSignalInfo.setGsm8Charset(isoCharset);
    ISDNAddressString callingPartyAddress = smRPOA.getMsisdn();
    if (callingPartyAddress == null) {
        throw new SmscProcessingException("MO callingPartyAddress is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    SmsTpdu smsTpdu = null;
    String origMoServiceCentreAddressDA = null;
    if (smRPDA.getServiceCentreAddressDA() != null) {
        origMoServiceCentreAddressDA = smRPDA.getServiceCentreAddressDA().getAddress();
    }
    try {
        smsTpdu = smsSignalInfo.decodeTpdu(true);
        switch(smsTpdu.getSmsTpduType()) {
            case SMS_SUBMIT:
                SmsSubmitTpdu smsSubmitTpdu = (SmsSubmitTpdu) smsTpdu;
                if (this.logger.isInfoEnabled()) {
                    this.logger.info("Received SMS_SUBMIT = " + smsSubmitTpdu);
                }
                sms = this.handleSmsSubmitTpdu(smsSubmitTpdu, callingPartyAddress, networkId, originatorSccpAddress, isMoOperation, dialog, evt, invokeId, origMoServiceCentreAddressDA);
                break;
            case SMS_DELIVER_REPORT:
                SmsDeliverReportTpdu smsDeliverReportTpdu = (SmsDeliverReportTpdu) smsTpdu;
                if (this.logger.isInfoEnabled()) {
                    this.logger.info("Received SMS_DELIVER_REPORT = " + smsDeliverReportTpdu);
                    smscStatAggregator.updateMsgInFailedAll();
                }
                // callingPartyAddress);
                break;
            case SMS_COMMAND:
                SmsCommandTpdu smsCommandTpdu = (SmsCommandTpdu) smsTpdu;
                if (this.logger.isInfoEnabled()) {
                    this.logger.info("Received SMS_COMMAND = " + smsCommandTpdu);
                    smscStatAggregator.updateMsgInFailedAll();
                }
                // callingPartyAddress);
                break;
            // break;
            default:
                this.logger.severe("Received non SMS_SUBMIT or SMS_DELIVER_REPORT or SMS_COMMAND or SMS_DELIVER = " + smsTpdu);
                smscStatAggregator.updateMsgInFailedAll();
                break;
        }
    } catch (MAPException e1) {
        logger.severe("Error while decoding SmsSignalInfo ", e1);
    }
    return sms;
}
Also used : MAPException(org.restcomm.protocols.ss7.map.api.MAPException) SmsTpdu(org.restcomm.protocols.ss7.map.api.smstpdu.SmsTpdu) MAPDialogSms(org.restcomm.protocols.ss7.map.api.service.sms.MAPDialogSms) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) SmsSubmitTpdu(org.restcomm.protocols.ss7.map.api.smstpdu.SmsSubmitTpdu) SmsDeliverReportTpdu(org.restcomm.protocols.ss7.map.api.smstpdu.SmsDeliverReportTpdu) SmsCommandTpdu(org.restcomm.protocols.ss7.map.api.smstpdu.SmsCommandTpdu)

Example 14 with MAPException

use of org.mobicents.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.

the class MtCommonSbb method onDeliveryError.

/**
 * Processing a case when an error in message sending process. This stops of message sending, reschedule or drop messages
 * and clear resources.
 *
 * @param smsSet
 * @param errorAction
 * @param smStatus
 * @param reason
 * @param removeSmsSet
 * @param errMessage
 * @param isImsiVlrReject
 * @param processingType
 */
protected void onDeliveryError(SmsSet smsSet, ErrorAction errorAction, ErrorCode smStatus, String reason, boolean removeSmsSet, MAPErrorMessage errMessage, boolean isImsiVlrReject, ProcessingType processingType) {
    try {
        smscStatAggregator.updateMsgOutFailedAll();
        // generating of a temporary failure CDR
        if (smscPropertiesManagement.getGenerateTempFailureCdr())
            this.generateTemporaryFailureCDR(CdrGenerator.CDR_TEMP_FAILED, reason);
        StringBuilder sb = new StringBuilder();
        sb.append("onDeliveryError: errorAction=");
        sb.append(errorAction);
        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());
        ArrayList<Sms> lstPermFailured = new ArrayList<Sms>();
        ArrayList<Sms> lstTempFailured = new ArrayList<Sms>();
        ArrayList<Sms> lstPermFailured2 = new ArrayList<Sms>();
        ArrayList<Sms> lstTempFailured2 = new ArrayList<Sms>();
        ArrayList<Sms> lstRerouted = new ArrayList<Sms>();
        ArrayList<Integer> lstNewNetworkId = new ArrayList<Integer>();
        // generate text for Delivery receipts
        // false
        String dlrText = null;
        if (errMessage != null) {
            MAPErrorMessageSMDeliveryFailure smDeliveryFailure = errMessage.getEmSMDeliveryFailure();
            if (smDeliveryFailure != null) {
                SmsDeliverReportTpdu tpdu = null;
                try {
                    tpdu = errMessage.getEmSMDeliveryFailure().getSmsDeliverReportTpdu();
                } catch (MAPException e) {
                // we ignore Exception here
                }
                if (tpdu != null) {
                    UserData userData = tpdu.getUserData();
                    if (userData != null) {
                        byte[] data = userData.getEncodedData();
                        if (data != null) {
                            String text = DatatypeConverter.printHexBinary(data);
                            String smDlrWithTpdu = SmscPropertiesManagement.getInstance().getSmDeliveryFailureDlrWithTpdu();
                            if (smDlrWithTpdu.equals("short")) {
                                if (text.length() > 20)
                                    dlrText = text.substring(0, 20);
                                else
                                    dlrText = text;
                            } else if (smDlrWithTpdu.equals("full")) {
                                dlrText = text;
                            }
                        }
                    }
                }
            }
        }
        TargetAddress lock = persistence.obtainSynchroObject(new TargetAddress(smsSet));
        synchronized (lock) {
            try {
                Date curDate = new Date();
                smsSet.setStatus(smStatus);
                // calculating of newDueDelay and NewDueTime
                int newDueDelay = calculateNewDueDelay(smsSet, (errorAction == ErrorAction.subscriberBusy));
                Date newDueTime = calculateNewDueTime(smsSet, newDueDelay);
                // creating of failure lists
                this.createFailureLists(lstPermFailured, lstTempFailured, errorAction, newDueTime);
                // mproc rules applying for delivery phase
                this.applyMprocRulesOnFailure(lstPermFailured, lstTempFailured, lstPermFailured2, lstTempFailured2, lstRerouted, lstNewNetworkId, processingType);
                // sending of a failure response for transactional mode
                this.sendTransactionalResponseFailure(lstPermFailured2, lstTempFailured2, errorAction, errMessage);
                // Processing messages that were temp or permanent failed or rerouted
                this.postProcessPermFailures(lstPermFailured2, null, null);
                this.postProcessTempFailures(smsSet, lstTempFailured2, newDueDelay, newDueTime, true);
                this.postProcessRerouted(lstRerouted, lstNewNetworkId);
                // generating CDRs for permanent failure messages
                this.generateCDRs(lstPermFailured2, (isImsiVlrReject ? CdrGenerator.CDR_FAILED_IMSI : CdrGenerator.CDR_FAILED), reason);
                // sending of intermediate delivery receipts
                this.generateIntermediateReceipts(smsSet, lstTempFailured2);
                // sending of failure delivery receipts
                this.generateFailureReceipts(smsSet, lstPermFailured2, dlrText);
                // sending of ReportSMDeliveryStatusRequest if needed
                SMDeliveryOutcome smDeliveryOutcome = null;
                switch(errorAction) {
                    case memoryCapacityExceededFlag:
                        smDeliveryOutcome = SMDeliveryOutcome.memoryCapacityExceeded;
                        break;
                    case mobileNotReachableFlag:
                        smDeliveryOutcome = SMDeliveryOutcome.absentSubscriber;
                        break;
                    case notReachableForGprs:
                        smDeliveryOutcome = SMDeliveryOutcome.absentSubscriber;
                        break;
                }
                if (smDeliveryOutcome != null && lstTempFailured2.size() > 0) {
                    Sms sms0 = smsSet.getSms(0);
                    String mtLocalSccpGt = null;
                    Integer mtRemoteSccpTt = null;
                    if (sms0 != null) {
                        mtLocalSccpGt = sms0.getMtLocalSccpGt();
                        mtRemoteSccpTt = sms0.getMtRemoteSccpTt();
                    }
                    this.setupReportSMDeliveryStatusRequest(smsSet.getDestAddr(), smsSet.getDestAddrTon(), smsSet.getDestAddrNpi(), smDeliveryOutcome, smsSet.getTargetId(), smsSet.getNetworkId(), mtLocalSccpGt, mtRemoteSccpTt);
                }
                this.markDeliveringIsEnded(removeSmsSet);
            } finally {
                persistence.releaseSynchroObject(lock);
            }
        }
    } catch (Throwable e) {
        logger.severe("Exception in MtCommonSbb.onDeliveryError(): " + e.getMessage(), e);
        markDeliveringIsEnded(true);
    }
}
Also used : UserData(org.restcomm.protocols.ss7.map.api.smstpdu.UserData) MAPException(org.restcomm.protocols.ss7.map.api.MAPException) ArrayList(java.util.ArrayList) MAPErrorMessageSMDeliveryFailure(org.restcomm.protocols.ss7.map.api.errors.MAPErrorMessageSMDeliveryFailure) TargetAddress(org.mobicents.smsc.library.TargetAddress) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) SMDeliveryOutcome(org.restcomm.protocols.ss7.map.api.service.sms.SMDeliveryOutcome) SmsDeliverReportTpdu(org.restcomm.protocols.ss7.map.api.smstpdu.SmsDeliverReportTpdu) Date(java.util.Date) Sms(org.mobicents.smsc.library.Sms)

Example 15 with MAPException

use of org.mobicents.protocols.ss7.map.api.MAPException in project smscgateway by RestComm.

the class MoSbb method createSmsEvent.

private Sms createSmsEvent(SmsSubmitTpdu smsSubmitTpdu, TargetAddress ta, PersistenceRAInterface store, AddressString callingPartyAddress, int networkId, String originatorSccpAddress) throws SmscProcessingException {
    UserData userData = smsSubmitTpdu.getUserData();
    try {
        userData.decode();
    } catch (MAPException e) {
        throw new SmscProcessingException("MO MAPException when decoding user data", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    Sms sms = new Sms();
    sms.setDbId(UUID.randomUUID());
    sms.setOriginationType(OriginationType.SS7_MO);
    // checking parameters first
    if (callingPartyAddress == null || callingPartyAddress.getAddress() == null || callingPartyAddress.getAddress().isEmpty()) {
        throw new SmscProcessingException("MO SourceAddress digits are absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    if (callingPartyAddress.getAddressNature() == null) {
        throw new SmscProcessingException("MO SourceAddress AddressNature is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    if (callingPartyAddress.getNumberingPlan() == null) {
        throw new SmscProcessingException("MO SourceAddress NumberingPlan is absent", SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    sms.setSourceAddr(callingPartyAddress.getAddress());
    sms.setOriginatorSccpAddress(originatorSccpAddress);
    sms.setSourceAddrTon(callingPartyAddress.getAddressNature().getIndicator());
    sms.setSourceAddrNpi(callingPartyAddress.getNumberingPlan().getIndicator());
    sms.setOrigNetworkId(networkId);
    sms.setSubmitDate(new Timestamp(System.currentTimeMillis()));
    int messageingMode = (smscPropertiesManagement.getMoDefaultMessagingMode() & 0x03);
    sms.setEsmClass(messageingMode | (smsSubmitTpdu.getUserDataHeaderIndicator() ? SmppConstants.ESM_CLASS_UDHI_MASK : 0) | (smsSubmitTpdu.getReplyPathExists() ? SmppConstants.ESM_CLASS_REPLY_PATH_MASK : 0));
    sms.setProtocolId(smsSubmitTpdu.getProtocolIdentifier().getCode());
    sms.setPriority(0);
    // TODO: do we need somehow care with RegisteredDelivery ?
    sms.setReplaceIfPresent(smsSubmitTpdu.getRejectDuplicates() ? 2 : 0);
    sms.setStatusReportRequest(smsSubmitTpdu.getStatusReportRequest());
    DataCodingScheme dataCodingScheme = smsSubmitTpdu.getDataCodingScheme();
    int dcs = dataCodingScheme.getCode();
    String err = MessageUtil.checkDataCodingSchemeSupport(dcs);
    if (err != null) {
        throw new SmscProcessingException("MO DataCoding scheme does not supported: " + dcs + " - " + err, SmppConstants.STATUS_SYSERR, MAPErrorCode.unexpectedDataValue, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null);
    }
    sms.setDataCoding(dcs);
    sms.setShortMessageText(userData.getDecodedMessage());
    UserDataHeader udh = userData.getDecodedUserDataHeader();
    if (udh != null) {
        sms.setShortMessageBin(udh.getEncodedData());
    }
    // ValidityPeriod processing
    ValidityPeriod vp = smsSubmitTpdu.getValidityPeriod();
    ValidityPeriodFormat vpf = smsSubmitTpdu.getValidityPeriodFormat();
    Date validityPeriod = null;
    if (vp != null && vpf != null && vpf != ValidityPeriodFormat.fieldNotPresent) {
        switch(vpf) {
            case fieldPresentAbsoluteFormat:
                AbsoluteTimeStamp ats = vp.getAbsoluteFormatValue();
                Date dt = new Date(ats.getYear(), ats.getMonth(), ats.getDay(), ats.getHour(), ats.getMinute(), ats.getSecond());
                int i1 = ats.getTimeZone() * 15 * 60;
                int i2 = -new Date().getTimezoneOffset() * 60;
                long i3 = (i2 - i1) * 1000;
                validityPeriod = new Date(dt.getTime() + i3);
                break;
            case fieldPresentRelativeFormat:
                validityPeriod = new Date(new Date().getTime() + (long) (vp.getRelativeFormatHours() * 3600 * 1000));
                break;
            case fieldPresentEnhancedFormat:
                this.logger.info("Recieved unsupported ValidityPeriodFormat: PresentEnhancedFormat - we skip it");
                break;
        }
    }
    MessageUtil.applyValidityPeriod(sms, validityPeriod, false, smscPropertiesManagement.getMaxValidityPeriodHours(), smscPropertiesManagement.getDefaultValidityPeriodHours());
    SmsSet smsSet;
    smsSet = new SmsSet();
    smsSet.setDestAddr(ta.getAddr());
    smsSet.setDestAddrNpi(ta.getAddrNpi());
    smsSet.setDestAddrTon(ta.getAddrTon());
    smsSet.setNetworkId(networkId);
    smsSet.addSms(sms);
    long messageId = store.c2_getNextMessageId();
    SmscStatProvider.getInstance().setCurrentMessageId(messageId);
    sms.setMessageId(messageId);
    sms.setMoMessageRef(smsSubmitTpdu.getMessageReference());
    return sms;
}
Also used : DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) AbsoluteTimeStamp(org.restcomm.protocols.ss7.map.api.smstpdu.AbsoluteTimeStamp) UserData(org.restcomm.protocols.ss7.map.api.smstpdu.UserData) MAPException(org.restcomm.protocols.ss7.map.api.MAPException) ISDNAddressString(org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString) AddressString(org.restcomm.protocols.ss7.map.api.primitives.AddressString) Timestamp(java.sql.Timestamp) Date(java.util.Date) ValidityPeriodFormat(org.restcomm.protocols.ss7.map.api.smstpdu.ValidityPeriodFormat) MAPDialogSms(org.restcomm.protocols.ss7.map.api.service.sms.MAPDialogSms) ValidityPeriod(org.restcomm.protocols.ss7.map.api.smstpdu.ValidityPeriod) UserDataHeader(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader)

Aggregations

MAPException (org.restcomm.protocols.ss7.map.api.MAPException)22 MAPDialogSms (org.restcomm.protocols.ss7.map.api.service.sms.MAPDialogSms)19 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)14 AddressString (org.restcomm.protocols.ss7.map.api.primitives.AddressString)12 ActivityContextInterface (javax.slee.ActivityContextInterface)4 Sms (org.mobicents.smsc.library.Sms)4 SmsSet (org.mobicents.smsc.library.SmsSet)4 SmsSignalInfo (org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo)4 MAPErrorMessage (org.restcomm.protocols.ss7.map.api.errors.MAPErrorMessage)3 MAPErrorMessageSubscriberBusyForMtSms (org.restcomm.protocols.ss7.map.api.errors.MAPErrorMessageSubscriberBusyForMtSms)3 SM_RP_DA (org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA)3 SmsTpdu (org.restcomm.protocols.ss7.map.api.smstpdu.SmsTpdu)3 UserData (org.restcomm.protocols.ss7.map.api.smstpdu.UserData)3 Timestamp (java.sql.Timestamp)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 SmscProcessingException (org.mobicents.smsc.library.SmscProcessingException)2 TargetAddress (org.mobicents.smsc.library.TargetAddress)2 MAPErrorMessageSMDeliveryFailure (org.restcomm.protocols.ss7.map.api.errors.MAPErrorMessageSMDeliveryFailure)2 IMSI (org.restcomm.protocols.ss7.map.api.primitives.IMSI)2