Search in sources :

Example 1 with MProcMessage

use of org.mobicents.smsc.mproc.MProcMessage in project smscgateway by RestComm.

the class MProcRuleDefaultTest method testTlvOptions.

@Test(groups = { "MProcRule" })
public void testTlvOptions() throws Exception {
    Sms sms = new Sms();
    MProcRuleDefaultImpl pmr = null;
    MProcMessage message = null;
    TlvSet tlvSet = null;
    // FIXME:add more failing tests
    // test tlvbyte_*
    tlvSet = new TlvSet();
    tlvSet.addOptionalParameter(new Tlv(SmppConstants.TAG_DEST_NETWORK_ID, new byte[] { 7 }));
    sms.setTlvSet(tlvSet);
    message = new MProcMessageImpl(sms, ProcessingType.SMPP, null);
    pmr = new MProcRuleDefaultImpl();
    pmr.setInitialRuleParameters("tlv_byte_1550 7");
    assertEquals(pmr.getRuleParameters(), "tlvByte_1550=7", "error");
    assertTrue(pmr.matchesPostArrival(message));
    tlvSet = new TlvSet();
    tlvSet.addOptionalParameter(new Tlv(SmppConstants.TAG_DEST_NETWORK_ID, new byte[] { 13 }));
    sms.setTlvSet(tlvSet);
    message = new MProcMessageImpl(sms, ProcessingType.SMPP, null);
    assertFalse(pmr.matchesPostArrival(message));
    pmr.setInitialRuleParameters("tlv_byte_1550 13");
    assertEquals(pmr.getRuleParameters(), "tlvByte_1550=13", "error");
    assertTrue(pmr.matchesPostArrival(message));
    // test tlvint_*
    tlvSet = new TlvSet();
    tlvSet.addOptionalParameter(new Tlv(SmppConstants.TAG_DEST_NETWORK_ID, new byte[] { 0, 0, 0, 7 }));
    sms.setTlvSet(tlvSet);
    message = new MProcMessageImpl(sms, ProcessingType.SMPP, null);
    pmr = new MProcRuleDefaultImpl();
    pmr.setInitialRuleParameters("tlv_int_1550 7");
    assertEquals(pmr.getRuleParameters(), "tlvInt_1550=7", "error");
    assertTrue(pmr.matchesPostArrival(message));
    tlvSet = new TlvSet();
    tlvSet.addOptionalParameter(new Tlv(SmppConstants.TAG_DEST_NETWORK_ID, new byte[] { 0, 0, 0, 13 }));
    sms.setTlvSet(tlvSet);
    message = new MProcMessageImpl(sms, ProcessingType.SMPP, null);
    assertFalse(pmr.matchesPostArrival(message));
    pmr.setInitialRuleParameters("tlv_int_1550 13");
    assertEquals(pmr.getRuleParameters(), "tlvInt_1550=13", "error");
    assertTrue(pmr.matchesPostArrival(message));
    // test tlvstring_*
    tlvSet = new TlvSet();
    tlvSet.addOptionalParameter(new Tlv(SmppConstants.TAG_DEST_NETWORK_ID, "7".getBytes()));
    sms.setTlvSet(tlvSet);
    message = new MProcMessageImpl(sms, ProcessingType.SMPP, null);
    pmr = new MProcRuleDefaultImpl();
    pmr.setInitialRuleParameters("tlv_string_1550 7");
    assertEquals(pmr.getRuleParameters(), "tlvString_1550=7", "error");
    assertTrue(pmr.matchesPostArrival(message));
    tlvSet = new TlvSet();
    tlvSet.addOptionalParameter(new Tlv(SmppConstants.TAG_DEST_NETWORK_ID, "13".getBytes()));
    sms.setTlvSet(tlvSet);
    message = new MProcMessageImpl(sms, ProcessingType.SMPP, null);
    assertFalse(pmr.matchesPostArrival(message));
    pmr.setInitialRuleParameters("tlv_string_1550 13");
    assertEquals(pmr.getRuleParameters(), "tlvString_1550=13", "error");
    assertTrue(pmr.matchesPostArrival(message));
}
Also used : Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage) TlvSet(org.restcomm.smpp.parameter.TlvSet) Tlv(com.cloudhopper.smpp.tlv.Tlv) Test(org.testng.annotations.Test)

Example 2 with MProcMessage

use of org.mobicents.smsc.mproc.MProcMessage in project smscgateway by RestComm.

the class MProcManagement method applyMProcImsiRequest.

public MProcResult applyMProcImsiRequest(final MProcRuleRaProvider anMProcRuleRa, Sms sms, String imsi, String nnnDigits, int nnnNumberingPlan, int nnnAddressNature) {
    if (this.mprocs.size() == 0)
        return new MProcResult();
    FastList<MProcRule> cur = this.mprocs;
    PostImsiProcessorImpl pap = new PostImsiProcessorImpl(logger);
    MProcMessage message = new MProcMessageImpl(sms, ProcessingType.SS7_SRI, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostImsiRequestState() && rule.matchesPostImsiRequest(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at ImsiRequest phase to a message:\nrule: " + rule + "\nmessage: " + sms);
                }
                rule.onPostImsiRequest(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or applyMProcImsiRequest(): " + e.getMessage(), e);
        return new MProcResult();
    }
    if (pap.isNeedDropMessages()) {
        MProcResult res = new MProcResult();
        res.setMessageDropped(true);
        return res;
    }
    if (pap.isNeedRerouteMessages()) {
        MProcResult res = new MProcResult();
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
        return res;
    }
    return new MProcResult();
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) FastList(javolution.util.FastList) MProcMessage(org.mobicents.smsc.mproc.MProcMessage) PostImsiProcessorImpl(org.mobicents.smsc.mproc.impl.PostImsiProcessorImpl)

Example 3 with MProcMessage

use of org.mobicents.smsc.mproc.MProcMessage in project smscgateway by RestComm.

the class MProcManagement method applyMProcHrSri.

public MProcResult applyMProcHrSri(final MProcRuleRaProvider anMProcRuleRa, CorrelationIdValue correlationIdValue) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostHrSriProcessorImpl pap = new PostHrSriProcessorImpl(logger);
    MProcMessage message = new MProcMessageHrImpl(correlationIdValue);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostHrSriState() && rule.matchesPostHrSri(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at HrSri phase to a message:\nrule: " + rule + "\ncorrelationIdValue: " + correlationIdValue);
                }
                rule.onPostHrSri(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostHrSri(): " + e.getMessage(), e);
        return new MProcResult();
    }
    MProcResult res = new MProcResult();
    if (pap.isHrByPassed()) {
        res.setHrIsByPassed(true);
    }
    return res;
}
Also used : MProcMessageHrImpl(org.mobicents.smsc.mproc.impl.MProcMessageHrImpl) MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) FastList(javolution.util.FastList) MProcMessage(org.mobicents.smsc.mproc.MProcMessage) PostHrSriProcessorImpl(org.mobicents.smsc.mproc.impl.PostHrSriProcessorImpl)

Example 4 with MProcMessage

use of org.mobicents.smsc.mproc.MProcMessage in project smscgateway by RestComm.

the class MProcManagement method applyMProcDelivery.

public MProcResult applyMProcDelivery(final MProcRuleRaProvider anMProcRuleRa, Sms sms, boolean deliveryFailure, ProcessingType processingType) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostDeliveryProcessorImpl pap = new PostDeliveryProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger, deliveryFailure);
    MProcMessage message = new MProcMessageImpl(sms, processingType, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostDeliveryState() && rule.matchesPostDelivery(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at Delivery phase to a message:\nrule: " + rule + "\nmessage: " + sms);
                }
                rule.onPostDelivery(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostDelivery(): " + e.getMessage(), e);
        return new MProcResult();
    }
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    res.setMessageList(res0);
    if (pap.isNeedRerouteMessages()) {
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
    }
    return res;
}
Also used : PostDeliveryProcessorImpl(org.mobicents.smsc.mproc.impl.PostDeliveryProcessorImpl) 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) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Example 5 with MProcMessage

use of org.mobicents.smsc.mproc.MProcMessage in project smscgateway by RestComm.

the class MProcManagement method applyMProcDeliveryTempFailure.

public MProcResult applyMProcDeliveryTempFailure(final MProcRuleRaProvider anMProcRuleRa, Sms sms, ProcessingType processingType) {
    if (this.mprocs.size() == 0) {
        return new MProcResult();
    }
    FastList<MProcRule> cur = this.mprocs;
    PostDeliveryTempFailureProcessorImpl pap = new PostDeliveryTempFailureProcessorImpl(this.smscPropertiesManagement.getDefaultValidityPeriodHours(), this.smscPropertiesManagement.getMaxValidityPeriodHours(), logger);
    MProcMessage message = new MProcMessageImpl(sms, processingType, null);
    try {
        for (FastList.Node<MProcRule> n = cur.head(), end = cur.tail(); (n = n.getNext()) != end; ) {
            MProcRule rule = n.getValue();
            if (rule.isForPostDeliveryTempFailureState() && rule.matchesPostDeliveryTempFailure(message)) {
                if (logger.isDebugEnabled()) {
                    logger.debug("MRule matches at DeliveryTempFailure phase to a message:\nrule: " + rule + "\nmessage: " + sms);
                }
                rule.onPostDeliveryTempFailure(anMProcRuleRa, pap, message);
            }
        }
    } catch (Throwable e) {
        logger.error("Exception when invoking rule.matches(message) or onPostDeliveryTempFailure(): " + e.getMessage(), e);
        return new MProcResult();
    }
    FastList<MProcNewMessage> newMsgs = pap.getPostedMessages();
    MProcResult res = new MProcResult();
    FastList<Sms> res0 = new FastList<Sms>();
    for (FastList.Node<MProcNewMessage> n = newMsgs.head(), end = newMsgs.tail(); (n = n.getNext()) != end; ) {
        MProcNewMessageImpl newMsg = (MProcNewMessageImpl) n.getValue();
        res0.add(newMsg.getSmsContent());
    }
    res.setMessageList(res0);
    if (pap.isNeedDropMessages()) {
        res.setMessageDropped(true);
    }
    if (pap.isNeedRerouteMessages()) {
        res.setMessageIsRerouted(true);
        res.setNewNetworkId(pap.getNewNetworkId());
    }
    return res;
}
Also used : MProcRule(org.mobicents.smsc.mproc.MProcRule) MProcNewMessage(org.mobicents.smsc.mproc.MProcNewMessage) FastList(javolution.util.FastList) PostDeliveryTempFailureProcessorImpl(org.mobicents.smsc.mproc.impl.PostDeliveryTempFailureProcessorImpl) MProcNewMessageImpl(org.mobicents.smsc.mproc.impl.MProcNewMessageImpl) MProcResult(org.mobicents.smsc.mproc.impl.MProcResult) MProcMessageImpl(org.mobicents.smsc.mproc.impl.MProcMessageImpl) Sms(org.mobicents.smsc.library.Sms) MProcMessage(org.mobicents.smsc.mproc.MProcMessage)

Aggregations

MProcMessage (org.mobicents.smsc.mproc.MProcMessage)9 FastList (javolution.util.FastList)6 Sms (org.mobicents.smsc.library.Sms)6 MProcRule (org.mobicents.smsc.mproc.MProcRule)6 MProcResult (org.mobicents.smsc.mproc.impl.MProcResult)6 MProcMessageImpl (org.mobicents.smsc.mproc.impl.MProcMessageImpl)5 MProcNewMessage (org.mobicents.smsc.mproc.MProcNewMessage)4 MProcNewMessageImpl (org.mobicents.smsc.mproc.impl.MProcNewMessageImpl)4 Tlv (com.cloudhopper.smpp.tlv.Tlv)2 TlvSet (org.restcomm.smpp.parameter.TlvSet)2 Test (org.testng.annotations.Test)2 Matcher (java.util.regex.Matcher)1 XMLStreamException (javolution.xml.stream.XMLStreamException)1 SmsSet (org.mobicents.smsc.library.SmsSet)1 DeliveryReceiptData (org.mobicents.smsc.mproc.DeliveryReceiptData)1 MProcMessageHrImpl (org.mobicents.smsc.mproc.impl.MProcMessageHrImpl)1 PostArrivalProcessorImpl (org.mobicents.smsc.mproc.impl.PostArrivalProcessorImpl)1 PostDeliveryProcessorImpl (org.mobicents.smsc.mproc.impl.PostDeliveryProcessorImpl)1 PostDeliveryTempFailureProcessorImpl (org.mobicents.smsc.mproc.impl.PostDeliveryTempFailureProcessorImpl)1 PostHrSriProcessorImpl (org.mobicents.smsc.mproc.impl.PostHrSriProcessorImpl)1