Search in sources :

Example 1 with PostDeliveryProcessorImpl

use of org.mobicents.smsc.mproc.impl.PostDeliveryProcessorImpl 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: rule: " + rule + "message: " + 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)

Aggregations

FastList (javolution.util.FastList)1 Sms (org.mobicents.smsc.library.Sms)1 MProcMessage (org.mobicents.smsc.mproc.MProcMessage)1 MProcNewMessage (org.mobicents.smsc.mproc.MProcNewMessage)1 MProcRule (org.mobicents.smsc.mproc.MProcRule)1 MProcMessageImpl (org.mobicents.smsc.mproc.impl.MProcMessageImpl)1 MProcNewMessageImpl (org.mobicents.smsc.mproc.impl.MProcNewMessageImpl)1 MProcResult (org.mobicents.smsc.mproc.impl.MProcResult)1 PostDeliveryProcessorImpl (org.mobicents.smsc.mproc.impl.PostDeliveryProcessorImpl)1