Search in sources :

Example 16 with TargetAddress

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

the class DeliveryCommonSbb method generateIntermediateReceipts.

/**
 * Generating of intermediate receipts for temporary failed messages
 *
 * @param smsSet
 * @param lstTempFailured
 */
protected void generateIntermediateReceipts(SmsSet smsSet, ArrayList<Sms> lstTempFailured) {
    if (!smscPropertiesManagement.getReceiptsDisabling() && smscPropertiesManagement.getEnableIntermediateReceipts()) {
        for (Sms sms : lstTempFailured) {
            // SMPP delivery receipt
            int registeredDelivery = sms.getRegisteredDelivery();
            if (MessageUtil.isReceiptIntermediate(registeredDelivery)) {
                TargetAddress ta = new TargetAddress(sms.getSourceAddrTon(), sms.getSourceAddrNpi(), sms.getSourceAddr(), smsSet.getNetworkId());
                Sms receipt = MessageUtil.createReceiptSms(sms, false, ta, smscPropertiesManagement.getOrigNetworkIdForReceipts(), null, true);
                this.sendNewGeneratedMessage(receipt, ta);
                this.logger.info("Adding an intermediate failure receipt: source=" + receipt.getSourceAddr() + ", dest=" + receipt.getSmsSet().getDestAddr());
            }
        }
    }
}
Also used : Sms(org.mobicents.smsc.library.Sms) TargetAddress(org.mobicents.smsc.library.TargetAddress)

Example 17 with TargetAddress

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

the class DeliveryCommonSbb method applyMprocRulesOnSuccess.

// *********
// applying of mproc rules
/**
 * mproc rules applying for delivery phase for success case
 *
 * @param sms
 * @param processingType
 */
protected void applyMprocRulesOnSuccess(Sms sms, ProcessingType processingType) {
    // PostDeliveryProcessor - success case
    MProcResult mProcResult = MProcManagement.getInstance().applyMProcDelivery(itsMProcRa, sms, false, processingType);
    FastList<Sms> addedMessages = mProcResult.getMessageList();
    if (addedMessages != null) {
        for (FastList.Node<Sms> n = addedMessages.head(), end = addedMessages.tail(); (n = n.getNext()) != end; ) {
            Sms smst = n.getValue();
            TargetAddress ta = new TargetAddress(smst.getSmsSet().getDestAddrTon(), smst.getSmsSet().getDestAddrNpi(), smst.getSmsSet().getDestAddr(), smst.getSmsSet().getNetworkId());
            this.sendNewGeneratedMessage(smst, ta);
            if (this.logger.isInfoEnabled()) {
                StringBuilder sb = new StringBuilder();
                sb.append("Posting of a new message after DeliverySuccess: targetId=");
                sb.append(smst.getSmsSet().getTargetId());
                sb.append(", sms=");
                sb.append(smst);
                this.logger.info(sb.toString());
            }
        }
    }
}
Also used : MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) Sms(org.mobicents.smsc.library.Sms) FastList(javolution.util.FastList) TargetAddress(org.mobicents.smsc.library.TargetAddress)

Example 18 with TargetAddress

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

the class CassandraTest method addingNewMessages.

public long addingNewMessages() throws Exception {
    Date dt = new Date();
    PreparedStatementCollection psc = sbb.getStatementCollection(dt);
    // adding 3 messages for "1111"
    TargetAddress lock = this.sbb.obtainSynchroObject(ta1);
    long dueSlot;
    try {
        synchronized (lock) {
            Sms sms_a1 = this.createTestSms(1, ta1.getAddr(), id1);
            Sms sms_a2 = this.createTestSms(2, ta1.getAddr(), id2);
            Sms sms_a3 = this.createTestSms(3, ta1.getAddr(), id3);
            dueSlot = this.sbb.c2_getDueSlotForTargetId(psc, ta1.getTargetId());
            if (dueSlot == 0 || dueSlot <= sbb.c2_getCurrentDueSlot()) {
                dueSlot = sbb.c2_getDueSlotForNewSms();
                sbb.c2_updateDueSlotForTargetId(ta1.getTargetId(), dueSlot);
            }
            sms_a1.setDueSlot(dueSlot);
            sms_a2.setDueSlot(dueSlot);
            sms_a3.setDueSlot(dueSlot);
            sbb.c2_registerDueSlotWriting(dueSlot);
            try {
                sbb.c2_createRecordCurrent(sms_a1);
                sbb.c2_createRecordCurrent(sms_a2);
                sbb.c2_createRecordCurrent(sms_a3);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
        }
    } finally {
        this.sbb.obtainSynchroObject(lock);
    }
    // adding a messages for "1112"
    lock = this.sbb.obtainSynchroObject(ta2);
    try {
        synchronized (lock) {
            Sms sms_a1 = this.createTestSms(4, ta2.getAddr(), id4);
            sbb.c2_updateDueSlotForTargetId(ta2.getTargetId(), dueSlot);
            sms_a1.setDueSlot(dueSlot);
            sbb.c2_registerDueSlotWriting(dueSlot);
            try {
                sbb.c2_createRecordCurrent(sms_a1);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
        }
    } finally {
        this.sbb.obtainSynchroObject(lock);
    }
    return dueSlot;
}
Also used : Sms(org.mobicents.smsc.library.Sms) TargetAddress(org.mobicents.smsc.library.TargetAddress) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection)

Example 19 with TargetAddress

use of org.mobicents.smsc.library.TargetAddress 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 20 with TargetAddress

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

the class CassandraTest method readAlertMessage.

public void readAlertMessage() throws Exception {
    Date dt = new Date();
    PreparedStatementCollection psc = sbb.getStatementCollection(dt);
    // reading "1112" for Alert
    TargetAddress lock = this.sbb.obtainSynchroObject(ta2);
    try {
        synchronized (lock) {
            long dueSlot = this.sbb.c2_getDueSlotForTargetId(psc, ta2.getTargetId());
            if (dueSlot == 0) {
                fail("Bad dueSlot for reading of ta2");
            }
            sbb.c2_registerDueSlotWriting(dueSlot);
            SmsSet smsSet;
            try {
                smsSet = sbb.c2_getRecordListForTargeId(dueSlot, ta2.getTargetId());
                ArrayList<SmsSet> lst0 = new ArrayList<SmsSet>();
                lst0.add(smsSet);
                ArrayList<SmsSet> lst = sbb.c2_sortRecordList(lst0);
            } finally {
                sbb.c2_unregisterDueSlotWriting(dueSlot);
            }
            assertEquals(smsSet.getSmsCount(), 1);
            Sms sms = smsSet.getSms(0);
            assertEquals(sms.getDueSlot(), dueSlot);
            this.checkTestSms(4, sms, id4, false);
            sbb.c2_updateInSystem(sms, DBOperations.IN_SYSTEM_INPROCESS, false);
        }
    } finally {
        this.sbb.obtainSynchroObject(lock);
    }
}
Also used : ArrayList(java.util.ArrayList) Sms(org.mobicents.smsc.library.Sms) TargetAddress(org.mobicents.smsc.library.TargetAddress) Date(java.util.Date) PreparedStatementCollection(org.mobicents.smsc.cassandra.PreparedStatementCollection) SmsSet(org.mobicents.smsc.library.SmsSet)

Aggregations

TargetAddress (org.mobicents.smsc.library.TargetAddress)34 Sms (org.mobicents.smsc.library.Sms)28 Date (java.util.Date)13 SmsSet (org.mobicents.smsc.library.SmsSet)13 ArrayList (java.util.ArrayList)10 SmscProcessingException (org.mobicents.smsc.library.SmscProcessingException)8 Esme (org.restcomm.smpp.Esme)8 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)7 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)7 FastList (javolution.util.FastList)6 MProcResult (org.mobicents.smsc.mproc.impl.MProcResult)6 EsmeManagement (org.restcomm.smpp.EsmeManagement)6 PersistenceException (org.mobicents.smsc.cassandra.PersistenceException)5 Test (org.testng.annotations.Test)5 CreateException (javax.slee.CreateException)4 AddressString (org.restcomm.protocols.ss7.map.api.primitives.AddressString)4 ErrorAction (org.mobicents.smsc.library.ErrorAction)3 ErrorCode (org.mobicents.smsc.library.ErrorCode)3 SmppSessionsProxy (org.mobicents.smsc.slee.resources.persistence.SmppSessionsProxy)3 MAPDialogSms (org.restcomm.protocols.ss7.map.api.service.sms.MAPDialogSms)3