Search in sources :

Example 6 with DataCodingSchemeImpl

use of org.mobicents.protocols.ss7.map.smstpdu.DataCodingSchemeImpl in project smscgateway by RestComm.

the class MtTest2 method Ucs2Test.

@Test(groups = { "Mt" })
public void Ucs2Test() throws Exception {
    // Long msgId = 15L;
    // String s1 = msgId.toString(10);
    // String sss2 = String.format("%010d", 15L);
    String s11 = "زمانیکه بررسی";
    Charset ucs2Charset = Charset.forName("UTF-16BE");
    Charset utf8 = Charset.forName("UTF-8");
    // ByteBuffer bb = ByteBuffer.wrap(textPart);
    // CharBuffer bf = ucs2Charset.decode(bb);
    // msg = bf.toString();
    ByteBuffer bb = utf8.encode(s11);
    byte[] buf = new byte[bb.limit()];
    bb.get(buf, 0, bb.limit());
    String s2 = new String(buf);
    UserDataImpl ud = new UserDataImpl(s2, new DataCodingSchemeImpl(8), null, null);
    AddressField originatingAddress = new AddressFieldImpl(TypeOfNumber.InternationalNumber, NumberingPlanIdentification.ISDNTelephoneNumberingPlan, "123456");
    ProtocolIdentifier pi = new ProtocolIdentifierImpl(0);
    AbsoluteTimeStamp serviceCentreTimeStamp = new AbsoluteTimeStampImpl(05, 3, 4, 5, 6, 7, 0);
    SmsDeliverTpduImpl smsDeliverTpduImpl = new SmsDeliverTpduImpl(false, false, false, true, originatingAddress, pi, serviceCentreTimeStamp, ud);
    SmsSignalInfoImpl SmsSignalInfoImpl = new SmsSignalInfoImpl(smsDeliverTpduImpl, null);
    int gg = 0;
    gg++;
}
Also used : AddressField(org.restcomm.protocols.ss7.map.api.smstpdu.AddressField) AbsoluteTimeStamp(org.restcomm.protocols.ss7.map.api.smstpdu.AbsoluteTimeStamp) AddressFieldImpl(org.restcomm.protocols.ss7.map.smstpdu.AddressFieldImpl) Charset(java.nio.charset.Charset) SmsSignalInfoImpl(org.restcomm.protocols.ss7.map.service.sms.SmsSignalInfoImpl) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) ByteBuffer(java.nio.ByteBuffer) ProtocolIdentifierImpl(org.restcomm.protocols.ss7.map.smstpdu.ProtocolIdentifierImpl) AbsoluteTimeStampImpl(org.restcomm.protocols.ss7.map.smstpdu.AbsoluteTimeStampImpl) UserDataImpl(org.restcomm.protocols.ss7.map.smstpdu.UserDataImpl) ProtocolIdentifier(org.restcomm.protocols.ss7.map.api.smstpdu.ProtocolIdentifier) SmsDeliverTpduImpl(org.restcomm.protocols.ss7.map.smstpdu.SmsDeliverTpduImpl) Test(org.testng.annotations.Test)

Example 7 with DataCodingSchemeImpl

use of org.mobicents.protocols.ss7.map.smstpdu.DataCodingSchemeImpl in project smscgateway by RestComm.

the class RxSipServerSbb method sendMessage.

// *********
// Main service methods
/**
 * Sending of a SIP message after initial message or when all sent messages was sent
 *
 * @param smsSet
 * @throws SmscProcessingException
 */
private void sendMessage(SmsSet smsSet) throws SmscProcessingException {
    smscStatAggregator.updateMsgOutTryAll();
    smscStatAggregator.updateMsgOutTrySip();
    Sms sms = this.obtainNextMessage(ProcessingType.SIP);
    if (sms == null) {
        this.markDeliveringIsEnded(true);
        return;
    }
    try {
        // TODO: let make here a special check if SIP is in a good state
        // if not - skip sending and set temporary error
        String fromAddressStr = sms.getSourceAddr();
        String toAddressStr = smsSet.getDestAddr();
        Sip sip = sipManagement.getSipByName(SipManagement.SIP_NAME);
        ListeningPoint listeningPoint = sipRA.getListeningPoints()[0];
        SipURI fromAddressUri = addressFactory.createSipURI(fromAddressStr, listeningPoint.getIPAddress() + ":" + listeningPoint.getPort());
        javax.sip.address.Address fromAddress = addressFactory.createAddress(fromAddressUri);
        FromHeader fromHeader = headerFactory.createFromHeader(fromAddress, null);
        SipURI toAddressUri = addressFactory.createSipURI(toAddressStr, sip.getSipAddress());
        javax.sip.address.Address toAddress = addressFactory.createAddress(toAddressUri);
        ToHeader toHeader = headerFactory.createToHeader(toAddress, null);
        List<ViaHeader> viaHeaders = new ArrayList<ViaHeader>(1);
        ViaHeader viaHeader = headerFactory.createViaHeader(listeningPoint.getIPAddress(), listeningPoint.getPort(), listeningPoint.getTransport(), null);
        viaHeaders.add(viaHeader);
        ContentTypeHeader contentTypeHeader = headerFactory.createContentTypeHeader("text", "plain");
        CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(2L, Request.MESSAGE);
        MaxForwardsHeader maxForwardsHeader = headerFactory.createMaxForwardsHeader(70);
        CallIdHeader callId = this.sipRA.getNewCallId();
        String msgStr = sms.getShortMessageText();
        byte[] msgUdh = sms.getShortMessageBin();
        byte[] msg;
        msg = recodeShortMessage(sms.getDataCoding(), msgStr, msgUdh);
        // create request
        Request request = messageFactory.createRequest(toAddressUri, Request.MESSAGE, callId, cSeqHeader, fromHeader, toHeader, viaHeaders, maxForwardsHeader, contentTypeHeader, msg);
        // Custom X Headers
        // SMSC-ID
        String originEsmeName = sms.getOrigEsmeName();
        if (originEsmeName != null) {
            Header smsIdHeader = headerFactory.createHeader(SipXHeaders.XSmscId, originEsmeName);
            request.addHeader(smsIdHeader);
        }
        // data-coding
        DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(sms.getDataCoding());
        Header smsIdHeader = headerFactory.createHeader(SipXHeaders.XSmsCoding, Integer.toString(dataCodingScheme.getCharacterSet().getCode()));
        request.addHeader(smsIdHeader);
        // TODO X header message class
        // X header delivery time, use SUBMIT_DATE
        Date submitDate = sms.getSubmitDate();
        if (submitDate != null) {
            String submitDateStr = MessageUtil.formatDate(submitDate);
            Header submitDateHeader = headerFactory.createHeader(SipXHeaders.XDeliveryTime, submitDateStr);
            request.addHeader(submitDateHeader);
        }
        // Validity Period
        Date validityPeriod = sms.getValidityPeriod();
        if (validityPeriod != null) {
            String validityPeriodStr = MessageUtil.formatDate(validityPeriod);
            Header validityHeader = headerFactory.createHeader(SipXHeaders.XSmsValidty, validityPeriodStr);
            request.addHeader(validityHeader);
        }
        // X header UDH
        if (msgUdh != null) {
            String udhString = hexStringToByteArray(msgUdh);
            Header udhHeader = headerFactory.createHeader(SipXHeaders.XSmsUdh, udhString);
            request.addHeader(udhHeader);
        }
        // create client transaction and send request
        ClientTransaction clientTransaction = sipRA.getNewClientTransaction(request);
        ActivityContextInterface sipClientTxaci = this.sipACIFactory.getActivityContextInterface(clientTransaction);
        sipClientTxaci.attach(this.sbbContext.getSbbLocalObject());
        clientTransaction.sendRequest();
    } catch (Exception e) {
        throw new SmscProcessingException("RxSipServerSbb.sendMessage(): Exception while trying to send SIP Message =" + e.getMessage() + "Message: " + sms, 0, 0, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e);
    }
}
Also used : MaxForwardsHeader(javax.sip.header.MaxForwardsHeader) DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) ArrayList(java.util.ArrayList) SipURI(javax.sip.address.SipURI) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) ToHeader(javax.sip.header.ToHeader) CallIdHeader(javax.sip.header.CallIdHeader) ActivityContextInterface(javax.slee.ActivityContextInterface) FromHeader(javax.sip.header.FromHeader) ContentTypeHeader(javax.sip.header.ContentTypeHeader) ClientTransaction(javax.sip.ClientTransaction) Request(javax.sip.message.Request) Date(java.util.Date) SmscProcessingException(org.mobicents.smsc.library.SmscProcessingException) CharacterCodingException(java.nio.charset.CharacterCodingException) CSeqHeader(javax.sip.header.CSeqHeader) ViaHeader(javax.sip.header.ViaHeader) CallIdHeader(javax.sip.header.CallIdHeader) Header(javax.sip.header.Header) CSeqHeader(javax.sip.header.CSeqHeader) ContentTypeHeader(javax.sip.header.ContentTypeHeader) MaxForwardsHeader(javax.sip.header.MaxForwardsHeader) ToHeader(javax.sip.header.ToHeader) FromHeader(javax.sip.header.FromHeader) ViaHeader(javax.sip.header.ViaHeader) Sms(org.mobicents.smsc.library.Sms) ListeningPoint(javax.sip.ListeningPoint) Sip(org.mobicents.smsc.domain.Sip)

Example 8 with DataCodingSchemeImpl

use of org.mobicents.protocols.ss7.map.smstpdu.DataCodingSchemeImpl in project smscgateway by RestComm.

the class CassandraTest method testingOldTimeEncoding.

@Test(groups = { "cassandra" })
public void testingOldTimeEncoding() throws Exception {
    if (!this.cassandraDbInited)
        return;
    this.sbb.setOldShortMessageDbFormat(true);
    DataCodingScheme dcsGsm7 = new DataCodingSchemeImpl(0);
    DataCodingScheme dcsUcs2 = new DataCodingSchemeImpl(8);
    DataCodingScheme dcsGsm8 = new DataCodingSchemeImpl(4);
    UserDataHeader udh = new UserDataHeaderImpl();
    UserDataHeaderElement informationElement = new ConcatenatedShortMessagesIdentifierImpl(false, 20, 5, 2);
    // boolean referenceIs16bit, int reference, int mesageSegmentCount, int
    // mesageSegmentNumber
    udh.addInformationElement(informationElement);
    TargetAddress ta = new TargetAddress(1, 1, "1111", 9);
    // GSM7 + UDH
    this.testOldFormatMessage(ta, dcsGsm7, "Test eng", udh, 1);
    // GSM7
    this.testOldFormatMessage(ta, dcsGsm7, "Test eng", null, 0);
    // UCS2 + UDH
    this.testOldFormatMessage(ta, dcsUcs2, "Test rus ������", udh, 0);
    // UCS2
    this.testOldFormatMessage(ta, dcsUcs2, "Test rus ������", null, 0);
    // GSM8
    this.testOldFormatMessage(ta, dcsGsm8, null, udh, 0);
}
Also used : DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) ConcatenatedShortMessagesIdentifierImpl(org.restcomm.protocols.ss7.map.smstpdu.ConcatenatedShortMessagesIdentifierImpl) UserDataHeaderImpl(org.restcomm.protocols.ss7.map.smstpdu.UserDataHeaderImpl) UserDataHeaderElement(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeaderElement) TargetAddress(org.mobicents.smsc.library.TargetAddress) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) UserDataHeader(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader) Test(org.testng.annotations.Test)

Example 9 with DataCodingSchemeImpl

use of org.mobicents.protocols.ss7.map.smstpdu.DataCodingSchemeImpl in project smscgateway by RestComm.

the class TxSmppServerSbb method parseShortMessageText.

private String parseShortMessageText(BaseSm event) {
    byte[] data = event.getShortMessage();
    if (event.getShortMessageLength() == 0) {
        // Probably the message_payload Optional Parameter is being used
        Tlv messagePaylod = event.getOptionalParameter(SmppConstants.TAG_MESSAGE_PAYLOAD);
        if (messagePaylod != null) {
            data = messagePaylod.getValue();
        }
    }
    if (data == null) {
        data = new byte[0];
    }
    boolean udhPresent = (event.getEsmClass() & SmppConstants.ESM_CLASS_UDHI_MASK) != 0;
    byte[] udhData;
    byte[] textPart;
    String msg;
    udhData = null;
    textPart = data;
    if (udhPresent && data.length > 2) {
        // UDH exists
        int udhLen = (textPart[0] & 0xFF) + 1;
        if (udhLen <= textPart.length) {
            textPart = new byte[textPart.length - udhLen];
            udhData = new byte[udhLen];
            System.arraycopy(data, udhLen, textPart, 0, textPart.length);
            System.arraycopy(data, 0, udhData, 0, udhLen);
        }
    }
    DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(event.getDataCoding());
    if (dataCodingScheme.getCharacterSet() == CharacterSet.GSM8) {
        msg = new String(textPart, isoCharset);
    } else {
        SmppEncoding enc;
        if (dataCodingScheme.getCharacterSet() == CharacterSet.GSM7) {
            enc = smscPropertiesManagement.getSmppEncodingForGsm7();
        } else {
            enc = smscPropertiesManagement.getSmppEncodingForUCS2();
        }
        switch(enc) {
            case Utf8:
            default:
                msg = new String(textPart, utf8Charset);
                break;
            case Unicode:
                msg = new String(textPart, ucs2Charset);
                break;
            case Gsm7:
                GSMCharsetDecoder decoder = (GSMCharsetDecoder) gsm7Charset.newDecoder();
                decoder.setGSMCharsetDecodingData(new GSMCharsetDecodingData(Gsm7EncodingStyle.bit8_smpp_style, Integer.MAX_VALUE, 0));
                ByteBuffer bb = ByteBuffer.wrap(textPart);
                CharBuffer bf = null;
                try {
                    bf = decoder.decode(bb);
                } catch (CharacterCodingException e) {
                // this can not be
                }
                msg = bf.toString();
                break;
        }
    }
    return msg;
}
Also used : DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) CharBuffer(java.nio.CharBuffer) SmppEncoding(org.restcomm.smpp.SmppEncoding) CharacterCodingException(java.nio.charset.CharacterCodingException) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) ByteBuffer(java.nio.ByteBuffer) GSMCharsetDecoder(org.restcomm.protocols.ss7.map.datacoding.GSMCharsetDecoder) GSMCharsetDecodingData(org.restcomm.protocols.ss7.map.datacoding.GSMCharsetDecodingData) Tlv(com.cloudhopper.smpp.tlv.Tlv)

Example 10 with DataCodingSchemeImpl

use of org.mobicents.protocols.ss7.map.smstpdu.DataCodingSchemeImpl in project smscgateway by RestComm.

the class TxSmppServerSbb method createSmsEventMulti.

protected SubmitMultiParseResult createSmsEventMulti(SubmitMulti event, Esme origEsme, PersistenceRAInterface store, int networkId) throws SmscProcessingException {
    List<Address> addrList = event.getDestAddresses();
    if (addrList == null || addrList.size() == 0) {
        throw new SmscProcessingException("For received SubmitMulti no DestAddresses found: ", SmppConstants.STATUS_INVDLNAME, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_DST_ADDR_INVALID);
    }
    if (event.getSourceAddress() == null || event.getSourceAddress().getAddress() == null || event.getSourceAddress().getAddress().isEmpty()) {
        throw new SmscProcessingException("SourceAddress digits are absent", SmppConstants.STATUS_INVSRCADR, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_SRC_ADDR_INVALID);
    }
    // checking parameters first
    String sourceAddr = event.getSourceAddress().getAddress();
    int sourceAddrTon = event.getSourceAddress().getTon();
    int sourceAddrNpi = event.getSourceAddress().getNpi();
    int dcs = event.getDataCoding();
    String err = MessageUtil.checkDataCodingSchemeSupport(dcs);
    if (err != null) {
        throw new SmscProcessingException("TxSmpp DataCoding scheme does not supported: " + dcs + " - " + err, SmppExtraConstants.ESME_RINVDCS, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_DATA_CODING_INVALID);
    }
    DataCodingScheme dataCodingScheme = new DataCodingSchemeImpl(dcs);
    boolean udhPresent = (event.getEsmClass() & SmppConstants.ESM_CLASS_UDHI_MASK) != 0;
    Tlv sarMsgRefNum = event.getOptionalParameter(SmppConstants.TAG_SAR_MSG_REF_NUM);
    Tlv sarTotalSegments = event.getOptionalParameter(SmppConstants.TAG_SAR_TOTAL_SEGMENTS);
    Tlv sarSegmentSeqnum = event.getOptionalParameter(SmppConstants.TAG_SAR_SEGMENT_SEQNUM);
    boolean segmentTlvFlag = (sarMsgRefNum != null && sarTotalSegments != null && sarSegmentSeqnum != null);
    // short message data
    byte[] data = event.getShortMessage();
    if (event.getShortMessageLength() == 0) {
        // Probably the message_payload Optional Parameter is being used
        Tlv messagePaylod = event.getOptionalParameter(SmppConstants.TAG_MESSAGE_PAYLOAD);
        if (messagePaylod != null) {
            data = messagePaylod.getValue();
        }
    }
    if (data == null) {
        data = new byte[0];
    }
    byte[] udhData;
    byte[] textPart;
    String msg;
    udhData = null;
    textPart = data;
    if (udhPresent && data.length > 2) {
        // UDH exists
        int udhLen = (textPart[0] & 0xFF) + 1;
        if (udhLen <= textPart.length) {
            textPart = new byte[textPart.length - udhLen];
            udhData = new byte[udhLen];
            System.arraycopy(data, udhLen, textPart, 0, textPart.length);
            System.arraycopy(data, 0, udhData, 0, udhLen);
        }
    }
    msg = parseShortMessageText(event);
    // checking max message length
    int nationalLanguageLockingShift = 0;
    int nationalLanguageSingleShift = 0;
    if (udhPresent || segmentTlvFlag) {
        // here splitting by SMSC is not supported
        UserDataHeader udh = null;
        int lenSolid = MessageUtil.getMaxSolidMessageBytesLength();
        if (udhPresent)
            udh = new UserDataHeaderImpl(udhData);
        else {
            udh = createNationalLanguageUdh(origEsme, dataCodingScheme);
            if (udh != null && udh.getNationalLanguageLockingShift() != null) {
                lenSolid -= 3;
                nationalLanguageLockingShift = udh.getNationalLanguageLockingShift().getNationalLanguageIdentifier().getCode();
            }
            if (udh != null && udh.getNationalLanguageSingleShift() != null) {
                lenSolid -= 3;
                nationalLanguageSingleShift = udh.getNationalLanguageSingleShift().getNationalLanguageIdentifier().getCode();
            }
        }
        int messageLen = MessageUtil.getMessageLengthInBytes(dataCodingScheme, msg, udh);
        if (udhData != null)
            messageLen += udhData.length;
        if (messageLen > lenSolid) {
            throw new SmscProcessingException("Message length in bytes is too big for solid message: " + messageLen + ">" + lenSolid, SmppConstants.STATUS_INVPARLEN, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_MSG_TOO_LONG);
        }
    } else {
        // here splitting by SMSC is supported
        int lenSegmented = MessageUtil.getMaxSegmentedMessageBytesLength();
        if (msg.length() * 2 > (lenSegmented - 6) * 255) {
            // firstly draft length check
            UserDataHeader udh = createNationalLanguageUdh(origEsme, dataCodingScheme);
            int messageLen = MessageUtil.getMessageLengthInBytes(dataCodingScheme, msg, udh);
            if (udh != null && udh.getNationalLanguageLockingShift() != null) {
                lenSegmented -= 3;
                nationalLanguageLockingShift = udh.getNationalLanguageLockingShift().getNationalLanguageIdentifier().getCode();
            }
            if (udh != null && udh.getNationalLanguageSingleShift() != null) {
                lenSegmented -= 3;
                nationalLanguageSingleShift = udh.getNationalLanguageSingleShift().getNationalLanguageIdentifier().getCode();
            }
            if (messageLen > lenSegmented * 255) {
                throw new SmscProcessingException("Message length in bytes is too big for segmented message: " + messageLen + ">" + lenSegmented, SmppConstants.STATUS_INVPARLEN, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, SmscProcessingException.INTERNAL_ERROR_MISC_MSG_TOO_LONG);
            }
        }
    }
    // ValidityPeriod processing
    Tlv tlvQosTimeToLive = event.getOptionalParameter(SmppConstants.TAG_QOS_TIME_TO_LIVE);
    Date validityPeriod;
    if (tlvQosTimeToLive != null) {
        long valTime;
        try {
            valTime = (new Date()).getTime() + tlvQosTimeToLive.getValueAsInt();
        } catch (TlvConvertException e) {
            throw new SmscProcessingException("TlvConvertException when getting TAG_QOS_TIME_TO_LIVE tlv field: " + e.getMessage(), SmppConstants.STATUS_INVOPTPARAMVAL, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_MISC_VALIDITY_PERIOD_PARSING);
        }
        validityPeriod = new Date(valTime);
    } else {
        try {
            validityPeriod = MessageUtil.parseSmppDate(event.getValidityPeriod());
        } catch (ParseException e) {
            throw new SmscProcessingException("ParseException when parsing ValidityPeriod field: " + e.getMessage(), SmppConstants.STATUS_INVEXPIRY, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_MISC_VALIDITY_PERIOD_PARSING);
        }
    }
    // ScheduleDeliveryTime processing
    Date scheduleDeliveryTime;
    try {
        scheduleDeliveryTime = MessageUtil.parseSmppDate(event.getScheduleDeliveryTime());
    } catch (ParseException e) {
        throw new SmscProcessingException("ParseException when parsing ScheduleDeliveryTime field: " + e.getMessage(), SmppConstants.STATUS_INVSCHED, MAPErrorCode.systemFailure, SmscProcessingException.HTTP_ERROR_CODE_NOT_SET, null, e, SmscProcessingException.INTERNAL_ERROR_MISC_SCHEDULER_DELIVERY_TIME_PARSING);
    }
    long messageId = store.c2_getNextMessageId();
    SmscStatProvider.getInstance().setCurrentMessageId(messageId);
    ArrayList<Sms> msgList = new ArrayList<Sms>(addrList.size());
    ArrayList<UnsucessfulSME> badAddresses = new ArrayList<UnsucessfulSME>(addrList.size());
    for (Address address : addrList) {
        boolean succAddr = false;
        TargetAddress ta = null;
        try {
            ta = createDestTargetAddress(address, networkId);
            succAddr = true;
        } catch (SmscProcessingException e) {
            Address addr = (Address) e.getExtraErrorData();
            if (addr != null) {
                UnsucessfulSME asme = new UnsucessfulSME(e.getSmppErrorCode(), addr);
                badAddresses.add(asme);
            }
        }
        if (succAddr) {
            Sms sms = new Sms();
            sms.setDbId(UUID.randomUUID());
            sms.setOriginationType(OriginationType.SMPP);
            sms.setSourceAddr(sourceAddr);
            sms.setSourceAddrTon(sourceAddrTon);
            sms.setSourceAddrNpi(sourceAddrNpi);
            sms.setOrigNetworkId(networkId);
            sms.setDataCoding(dcs);
            sms.setNationalLanguageLockingShift(nationalLanguageLockingShift);
            sms.setNationalLanguageSingleShift(nationalLanguageSingleShift);
            sms.setOrigSystemId(origEsme.getSystemId());
            sms.setOrigEsmeName(origEsme.getName());
            sms.setSubmitDate(new Timestamp(System.currentTimeMillis()));
            sms.setServiceType(event.getServiceType());
            sms.setEsmClass(event.getEsmClass());
            sms.setProtocolId(event.getProtocolId());
            sms.setPriority(event.getPriority());
            sms.setRegisteredDelivery(event.getRegisteredDelivery());
            sms.setReplaceIfPresent(event.getReplaceIfPresent());
            sms.setDefaultMsgId(event.getDefaultMsgId());
            sms.setShortMessageText(msg);
            sms.setShortMessageBin(udhData);
            MessageUtil.applyValidityPeriod(sms, validityPeriod, true, smscPropertiesManagement.getMaxValidityPeriodHours(), smscPropertiesManagement.getDefaultValidityPeriodHours());
            MessageUtil.applyScheduleDeliveryTime(sms, scheduleDeliveryTime);
            // storing additional parameters
            ArrayList<Tlv> optionalParameters = event.getOptionalParameters();
            if (optionalParameters != null && optionalParameters.size() > 0) {
                for (Tlv tlv : optionalParameters) {
                    if (tlv.getTag() != SmppConstants.TAG_MESSAGE_PAYLOAD) {
                        sms.getTlvSet().addOptionalParameter(tlv);
                    }
                }
            }
            SmsSet smsSet;
            smsSet = new SmsSet();
            smsSet.setDestAddr(ta.getAddr());
            smsSet.setDestAddrNpi(ta.getAddrNpi());
            smsSet.setDestAddrTon(ta.getAddrTon());
            smsSet.setNetworkId(origEsme.getNetworkId());
            smsSet.addSms(sms);
            sms.setSmsSet(smsSet);
            sms.setMessageId(messageId);
            msgList.add(sms);
        }
    }
    return new SubmitMultiParseResult(msgList, badAddresses);
}
Also used : DataCodingScheme(org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme) UserDataHeaderImpl(org.restcomm.protocols.ss7.map.smstpdu.UserDataHeaderImpl) Address(com.cloudhopper.smpp.type.Address) UnsucessfulSME(com.cloudhopper.smpp.type.UnsucessfulSME) ArrayList(java.util.ArrayList) DataCodingSchemeImpl(org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl) Timestamp(java.sql.Timestamp) UserDataHeader(org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader) Tlv(com.cloudhopper.smpp.tlv.Tlv) TlvConvertException(com.cloudhopper.smpp.tlv.TlvConvertException) Date(java.util.Date) ParseException(java.text.ParseException)

Aggregations

DataCodingSchemeImpl (org.restcomm.protocols.ss7.map.smstpdu.DataCodingSchemeImpl)24 DataCodingScheme (org.restcomm.protocols.ss7.map.api.smstpdu.DataCodingScheme)18 Test (org.testng.annotations.Test)12 Date (java.util.Date)11 Sms (org.mobicents.smsc.library.Sms)10 UserDataHeader (org.restcomm.protocols.ss7.map.api.smstpdu.UserDataHeader)8 ByteBuffer (java.nio.ByteBuffer)7 SmsSet (org.mobicents.smsc.library.SmsSet)7 AddressField (org.restcomm.protocols.ss7.map.api.smstpdu.AddressField)7 ProtocolIdentifier (org.restcomm.protocols.ss7.map.api.smstpdu.ProtocolIdentifier)7 SmsSignalInfoImpl (org.restcomm.protocols.ss7.map.service.sms.SmsSignalInfoImpl)7 AddressFieldImpl (org.restcomm.protocols.ss7.map.smstpdu.AddressFieldImpl)7 ProtocolIdentifierImpl (org.restcomm.protocols.ss7.map.smstpdu.ProtocolIdentifierImpl)7 UserDataImpl (org.restcomm.protocols.ss7.map.smstpdu.UserDataImpl)7 CharacterCodingException (java.nio.charset.CharacterCodingException)6 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)6 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)6 AddressString (org.restcomm.protocols.ss7.map.api.primitives.AddressString)6 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)6 SM_RP_DA (org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA)6