Search in sources :

Example 76 with Sms

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

the class MProcManagement method applyMProcArrival.

public MProcResult applyMProcArrival(final MProcRuleRaProvider anMProcRuleRa, Sms sms, PersistenseCommonInterface persistence) {
    if (this.mprocs.size() == 0) {
        FastList<Sms> res0 = new FastList<Sms>();
        res0.add(sms);
        MProcResult res = new MProcResult();
        res.setMessageList(res0);
        return res;
    }
    FastList<MProcRule> cur = this.mprocs;
    PostArrivalProcessorImpl pap = new PostArrivalProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, null, persistence);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostArrivalState() && rule.matchesPostArrival(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at Arrival phase to a message: rule: " + rule + "message: " + sms);
                }
                pap.setRuleIdInProcessing(rule.getId());
                rule.onPostArrival(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or applyMProcArrival: " + e.getMessage(), e);
        MProcResult res = new MProcResult();
        res.setMessageDropped(true);
        return res;
    }
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    res.setMessageList(res0);
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    if (pap.isNeedDropMessage()) {
        res.setMessageDropped(true);
        res.setRuleIdDropReject(pap.getRuleIdDropReject());
    } else if (pap.isNeedRejectMessage()) {
        res.setMessageRejected(true);
        // res.setMprocRejectingRuleId(pap.);
        res.setMapErrorCode(pap.getMapErrorCode());
        res.setHttpErrorCode(pap.getHttpErrorCode());
        res.setSmppErrorCode(pap.getSmppErrorCode());
        res.setRuleIdDropReject(pap.getRuleIdDropReject());
    } else {
        res0.add(sms);
    }
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) PostArrivalProcessorImpl(org.mobicents.smsc.mproc.impl.PostArrivalProcessorImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Example 77 with Sms

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

the class CassandraTest method testingMsgIsArchive.

@Test(groups = { "cassandra" })
public void testingMsgIsArchive() throws Exception {
    if (!this.cassandraDbInited)
        return;
    Sms sms_a1 = this.createTestSms(1, ta1.getAddr(), id1);
    SmsSet smsSet = sms_a1.getSmsSet();
    archiveMessage2(smsSet);
}
Also used : Sms(org.mobicents.smsc.library.Sms) SmsSet(org.mobicents.smsc.library.SmsSet) Test(org.testng.annotations.Test)

Example 78 with Sms

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

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

the class CassandraTest method archiveMessage.

public void archiveMessage(SmsSet smsSet, String[] remoteMessageId, String esmeId) throws Exception {
    for (int i1 = 0; i1 < 3; i1++) {
        Sms sms = smsSet.getSms(i1);
        sms.getSmsSet().setType(SmType.SMS_FOR_SS7);
        sms.getSmsSet().setImsi("12345678900000");
        ISDNAddressStringImpl networkNodeNumber = new ISDNAddressStringImpl(AddressNature.international_number, NumberingPlan.ISDN, "2223334444");
        LocationInfoWithLMSIImpl locationInfoWithLMSI = new LocationInfoWithLMSIImpl(networkNodeNumber, null, null, false, null);
        sms.getSmsSet().setLocationInfoWithLMSI(locationInfoWithLMSI);
        sbb.c2_createRecordArchive(sms, remoteMessageId[i1], esmeId, true, true);
    }
    Sms sms = smsSet.getSms(0);
    SmsProxy smsx = sbb.obtainArchiveSms(sms.getDueSlot(), sms.getSmsSet().getDestAddr(), sms.getDbId());
    this.checkTestSms(1, smsx.sms, sms.getDbId(), true);
    Sms smsy = sbb.c2_getRecordArchiveForMessageId(sms.getMessageId());
    this.checkTestSms(1, smsy, sms.getDbId(), true);
    Long messageId = sbb.c2_getMessageIdByRemoteMessageId(remoteMessageId[0], esmeId);
    assertNotNull(messageId);
    assertEquals((long) messageId, sms.getMessageId());
}
Also used : ISDNAddressStringImpl(org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl) Sms(org.mobicents.smsc.library.Sms) LocationInfoWithLMSIImpl(org.restcomm.protocols.ss7.map.service.sms.LocationInfoWithLMSIImpl)

Example 80 with Sms

use of org.mobicents.smsc.library.Sms 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

Sms (org.mobicents.smsc.library.Sms)139 SmsSet (org.mobicents.smsc.library.SmsSet)62 Test (org.testng.annotations.Test)43 Date (java.util.Date)42 ArrayList (java.util.ArrayList)35 ISDNAddressString (org.restcomm.protocols.ss7.map.api.primitives.ISDNAddressString)33 TargetAddress (org.mobicents.smsc.library.TargetAddress)30 MAPDialogSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPDialogSmsProxy)27 MAPServiceSmsProxy (org.mobicents.smsc.slee.resources.persistence.MAPServiceSmsProxy)27 ISDNAddressStringImpl (org.restcomm.protocols.ss7.map.primitives.ISDNAddressStringImpl)26 AddressString (org.restcomm.protocols.ss7.map.api.primitives.AddressString)24 SmscPropertiesManagement (org.mobicents.smsc.domain.SmscPropertiesManagement)23 UUID (java.util.UUID)22 PreparedStatementCollection (org.mobicents.smsc.cassandra.PreparedStatementCollection)21 SmsSetEvent (org.mobicents.smsc.slee.services.smpp.server.events.SmsSetEvent)21 SmsProxy (org.mobicents.smsc.slee.resources.persistence.SmsProxy)20 SM_RP_DA (org.restcomm.protocols.ss7.map.api.service.sms.SM_RP_DA)19 SmsSignalInfo (org.restcomm.protocols.ss7.map.api.service.sms.SmsSignalInfo)19 MAPApplicationContextVersion (org.restcomm.protocols.ss7.map.api.MAPApplicationContextVersion)17 UserData (org.restcomm.protocols.ss7.map.api.smstpdu.UserData)17