Search in sources :

Example 1 with NumberingPlan

use of org.mobicents.protocols.ss7.indicator.NumberingPlan 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.mobicents.protocols.ss7.map.api.smstpdu.DataCodingScheme) AbsoluteTimeStamp(org.mobicents.protocols.ss7.map.api.smstpdu.AbsoluteTimeStamp) UserData(org.mobicents.protocols.ss7.map.api.smstpdu.UserData) 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) Timestamp(java.sql.Timestamp) Date(java.util.Date) ValidityPeriodFormat(org.mobicents.protocols.ss7.map.api.smstpdu.ValidityPeriodFormat) MAPDialogSms(org.mobicents.protocols.ss7.map.api.service.sms.MAPDialogSms) ValidityPeriod(org.mobicents.protocols.ss7.map.api.smstpdu.ValidityPeriod) UserDataHeader(org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeader)

Example 2 with NumberingPlan

use of org.mobicents.protocols.ss7.indicator.NumberingPlan in project smscgateway by RestComm.

the class MessageUtil method getSccpAddress.

public static SccpAddress getSccpAddress(ParameterFactory sccpParameterFact, String address, int ton, int npi, int ssn, GlobalTitleIndicator gti, int translationType) {
    NumberingPlan np = MessageUtil.getSccpNumberingPlan(npi);
    NatureOfAddress na = MessageUtil.getSccpNatureOfAddress(ton);
    GlobalTitle gt;
    switch(gti) {
        case GLOBAL_TITLE_INCLUDES_TRANSLATION_TYPE_NUMBERING_PLAN_ENCODING_SCHEME_AND_NATURE_OF_ADDRESS:
            gt = sccpParameterFact.createGlobalTitle(address, translationType, np, null, na);
            break;
        case GLOBAL_TITLE_INCLUDES_TRANSLATION_TYPE_NUMBERING_PLAN_AND_ENCODING_SCHEME:
            gt = sccpParameterFact.createGlobalTitle(address, translationType, np, null);
            break;
        case GLOBAL_TITLE_INCLUDES_NATURE_OF_ADDRESS_INDICATOR_ONLY:
            gt = sccpParameterFact.createGlobalTitle(address, na);
            break;
        case GLOBAL_TITLE_INCLUDES_TRANSLATION_TYPE_ONLY:
            gt = sccpParameterFact.createGlobalTitle(address, translationType);
            break;
        default:
            gt = sccpParameterFact.createGlobalTitle(address, translationType, np, null, na);
            break;
    }
    return sccpParameterFact.createSccpAddress(RoutingIndicator.ROUTING_BASED_ON_GLOBAL_TITLE, gt, 0, ssn);
}
Also used : GlobalTitle(org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle) NumberingPlan(org.mobicents.protocols.ss7.indicator.NumberingPlan) NatureOfAddress(org.mobicents.protocols.ss7.indicator.NatureOfAddress)

Aggregations

Timestamp (java.sql.Timestamp)1 Date (java.util.Date)1 NatureOfAddress (org.mobicents.protocols.ss7.indicator.NatureOfAddress)1 NumberingPlan (org.mobicents.protocols.ss7.indicator.NumberingPlan)1 MAPException (org.mobicents.protocols.ss7.map.api.MAPException)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 AbsoluteTimeStamp (org.mobicents.protocols.ss7.map.api.smstpdu.AbsoluteTimeStamp)1 DataCodingScheme (org.mobicents.protocols.ss7.map.api.smstpdu.DataCodingScheme)1 UserData (org.mobicents.protocols.ss7.map.api.smstpdu.UserData)1 UserDataHeader (org.mobicents.protocols.ss7.map.api.smstpdu.UserDataHeader)1 ValidityPeriod (org.mobicents.protocols.ss7.map.api.smstpdu.ValidityPeriod)1 ValidityPeriodFormat (org.mobicents.protocols.ss7.map.api.smstpdu.ValidityPeriodFormat)1 GlobalTitle (org.mobicents.protocols.ss7.sccp.parameter.GlobalTitle)1